On Fri, Mar 13, 2009 at 12:46 PM, Stefan Behnel <[email protected]> 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? >
Well, take for granted that if this were available, I would use it in mpi4py. For example, some instances of cdef classes could be specially handled, and I could easily implement things like in the code below: comm = MPI.Comm(MPI.COMM_WORLD) assert comm is MPI.COMM_WORLD and the assertion will succeed... Moreover, any cdef class whose instances are intended to be immutable (like int, str, float, tuple) could benefit from this feature, such in the same way that core CPython does. -- Lisandro Dalcín --------------- Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) PTLC - Güemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594 _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
