[Numpy-discussion] Ransom Proposals

Tim Hochberg tim.hochberg at cox.net
Mon Mar 27 14:09:03 CST 2006

Travis Oliphant wrote:

> Tim Hochberg wrote:
>>> Yes, having this ability means that you have to think about it a bit 
>>> if you are going to use the functional interface and try to do 
>>> in-place operations.  But, I would argue that this is an "advanced" 
>>> usage which is implemented to save space and time.
>> How is this true though? In what way, for instance, is:
>>    b = asarray(a).reshape(newshape)
>> slower or less space efficient than todays:
>>    b = reshape(a)
> Well, the big difference is that b=reshape(a) is actually
> try:
>     reshape = a.reshape
> except AttributeError:
>     return a.__array_wrap__(asarray(a).reshape(newshape))
> return reshape(newshape)
> So, it handles more cases, more cleanly then the 
> asarray(a).rehsape(newshape) approach does.

OK. Although I should have said asanyarray(a).reshape(newshape),  I 
still see how that this handles more cases. I do not agree that it is 
worth the attendant drawbacks and I would still like to see these 
functions spun off into a separate namespace.

I need to go think about this case some more. This is not something that 
I've run into in practice, but I can see I'll have a stronger case if I 
can come up with a alternative to this in terms of safe functions. Do 
you have some examples of objects that do not have 'reshape', but do 
have '__array_wrap__'?


More information about the Numpy-discussion mailing list