[Numpy-discussion] proper use of __new__

Matthew Brett matthew.brett at gmail.com
Tue Jul 21 14:41:15 EDT 2009


Hi,

>> I'm the person who removed the reference to thread-safeness in the
>> numpy version of the subclassing docs.   I remember at the time going
>> through all the email discussions that led up to the thread-safeness
>> question, and concluding (in discussion with Travis O and others) that
>> there was not an increased threading problem with __new__  but
>> understanding why it came up in the first place.  I can't now
>> reconstruct that understanding, I could have a go if y'all want some
>> summary...
>
> Did this occur on the mailing list? Could you provide a link?

Yes, here's the link:

http://mail.scipy.org/pipermail/numpy-discussion/2007-February/025922.html

I remember the argument now.  Sturla Molden was pointing out that iff
you modify attributes at the class level in __new__, this is not
thread safe - as happens with any global variable.  Usually of course
you don't modify class attributes in the __new__ method, and in that
case, expect no subclass threading problems.  The key post from Travis
here:

http://mail.scipy.org/pipermail/numpy-discussion/2007-February/025971.html

Matthew



More information about the NumPy-Discussion mailing list