On Mar 15, 2009, at 2:48 PM, Greg Ewing wrote:

> Stefan Behnel wrote:
>> Carl Witty wrote:
>>
>>> Hmm... I hope that eventually Cython will allow overriding  
>>> __new__, at
>>> which point calling an extension type won't necessarily return a  
>>> value
>>> of that type.
>>
>> I'm not sure. This should certainly be supported for Python  
>> classes, but
>> for extension types? What would be the use case?
>
> If it is supported, it could perhaps be handled by allowing
> the return type of the __new__ method to be declared explicitly,
> defaulting to the class. E.g. given
>
>    cdef class Foo:
>      def __new__(cls, ..):
>        ...
>
> then Foo() is assumed to return something of type Foo, but
> given
>
>    cdef class Blarg:
>      def object __new__(cls, ..):
>        ...
>
> then Blarg() could return any type of object.

This sounds like a good syntax.

- Robert

_______________________________________________
Cython-dev mailing list
Cython-dev@codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to