ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> numpy-discussion
numpy-discussion
Re: [Numpy-discussion] Behavior of array scalars
by Sasha other posts by this author
Feb 17 2006 3:44PM messages near this date
Re: [Numpy-discussion] Behavior of array scalars | Re: [Numpy-discussion] Behavior of array scalars
On 2/17/06, Travis Oliphant <oliphant@[...].edu>  wrote:
>  ...
>  Perhaps what is going on is that
>  a += 10
>  is begin translated to
>  a = a + 10
>  rather than
>  add(a,10,a)
>  I'll have to look deeper to see why.

It is actually being translated to "a = add(a,10,a)" by virtue of
array_inplace_add supplied in the inplace_add slot.  Here is the
proof:

> >> a = array(0)
> >> a = b = array(0)
> >> a += 10
> >> b
array(10)
> >> a
10

Another way to explain it is to note that a += 10 is equivalent to "a
= a.__iadd__(10)" and a.__iadd__(10) is equivalent to "add(a, 10, a)".

This is not easy to fix because the real culprit is

> >> a = array(0)
> >> type(a) is type(a+a)
False

Maybe we can change ufunc logic so that when the output argument is
supplied it is returned without scalar conversion.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@[...].net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Thread:
Christopher Barker
Travis Oliphant
Sasha
Travis Oliphant
Christopher Barker
Sasha
Travis Oliphant
David M. Cooke
Sasha
Travis Oliphant
Travis Oliphant
Sasha
Travis Oliphant
Sasha
Alexander Belopolsky
Sasha

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved