Robert Bradshaw, 25.11.2009 04:27: > On Nov 24, 2009, at 1:18 PM, Lisandro Dalcin wrote: >>> Joachim Saul, 24.11.2009 20:59: >>>> cdef extern from "Python.h": >>>> ctypedef class __builtin__.str [object PyStringObject]: >>>> pass >> >> Anyway, any good reason for such code to fail in Cython? Should we >> support such declarations of builtin types? I think Cython should be >> able to compile as much Pyrex code as possible. > > I agree, it shouldn't fail (though perhaps there should be a warning). > The underlying issue is that it doesn't recognize that the user- > declared type could be compatible with the builtin type. We should > recognize this and allow it.
I disagree. This would either require us to check the declaration exactly (in which case there would be zero gain at all, as Cython would need to know the complete type declaration already), or it would allow users to declare all sorts of broken things on the type without checking. The latter means that there could be all sorts of surprises for users that see their code work or fail, depending on what they think they have declared. I think the right way to handle this would be to finish up subtyping support and type fields for builtin types (IIRC, that's what's still missing?), and then emit either an error on the above, or a clear warning that states that the senseless redefinition of a builtin type has been ignored (which IMHO is a very good argument for making it an error). Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
