[Numpy-discussion] Release of 1.0b5 this weekend

Travis Oliphant oliphant at ee.byu.edu
Tue Aug 29 15:43:14 CDT 2006

Tim Hochberg wrote:

>-0.5 from me if what we're talking about here is having mutating methods 
>return self rather than None. Chaining stuff is pretty, but having 
>methods that mutate self and return self looks like a source of elusive 
>bugs to me.

I'm generally +0 on this idea (it seems like the clarity in writing 
comes largely for interactive users), and don't see much difficulty in 
separating the constructs.   On the other hand, I don't see much problem 
in returning a reference to self either.  

I guess you are worried about the situation where you write

b = a.sort()

and think you have a new array, but in fact have a new reference to the 
already-altered 'a'?

Hmm..  So, how is this different from the fact that

b = a[1:10:3] already returns a reference to 'a'

(I suppose in the fact that it actually returns a new object just one 
that happens to share the same data with a).

However, I suppose that other methods don't return a reference to an 
already-altered object, do they. 

Tim's argument has moved me from +0 to -0


More information about the Numpy-discussion mailing list