Numeric write-in place facility

David Ascher da at ski.org
Mon Nov 29 16:11:41 EST 1999


On Mon, 29 Nov 1999, Ionel Simionescu wrote:

> Hi,
> 
> In a post on the wxPython list, Markus Gritsch suggested that array ops such
> as
> a = a+b
> can be done faster by using write-in place:
> Numric.add(a,b,a)
> 
> Playing around I see now that other ufuncs allow a write-in target
> specification as their last argument. For example,
> 
> Numeric.sqrt(a,b)
> 
> will put the result in b (if its dimension and type are Ok).
> 
> The docs do not tell much about this.
> Can anyone confirm/clarify/comment ?

1) Confirm: yes
2) Clarify: well, I think you pretty much summed it up
3) Comment: Watch out for 'slices'.  If you do

a = arange(10)
b = a[::-1]
add(a,b,b)
print b

you might be suprised =)

--david ascher





More information about the Python-list mailing list