Robert Bradshaw, 02.11.2010 23:21:
> On Tue, Nov 2, 2010 at 3:11 PM, Vitja Makarov wrote:
>> http://docs.python.org/reference/datamodel.html#basic-customization
>>
>> """Called to create a new instance of class cls. __new__() is a static
>> method (special-cased so you need not declare it as such) that takes
>> the class of which an instance was requested as its first argument.
>> The remaining arguments are those passed to the object constructor
>> expression (the call to the class). The return value of __new__()
>> should be the new object instance (usually an instance of cls)."""
>
> I was actually thinking about cdef classes, where __new__ is much more
> subtle. I didn't realize it was a static method that takes the class
> as a first argument rather than just a class method.

It needs to be to support inheritance. You usually call the __new__ method 
of the superclass to create the instance that you return. So you must be 
able to pass the required class through the hierarchy explicitly.

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to