On Nov 25, 2009, at 1:38 PM, Stefan Behnel wrote: > Hi Greg, > > Greg Ewing, 25.11.2009 21:04: >> The code in question works in Pyrex because the type of the >> default argument is checked dynamically at run time, just >> like in any other assignment. Cython appears to be making an >> excessively static determination of the type here. > > Ah, right, that's due to the str/bytes/unicode separation in 0.12. > Cython > now generates errors when you try to assign one to the other. I > think that > strikes here, too, as the OP's code was trying to assign one of them > to an > unrelated extension type. > > This makes the behaviour appear more like a side-effect than a well > designed feature. > > >> Having full builtin declarations for all the standard types >> would be useful, but as long as external type definitions are >> allowed at all, you can't eliminate the possibility that the >> user will declare a type in a way that doesn't agree with >> reality. At some point you just have to trust the programmer, >> lest you cripple them unnecessarily.
+1 > This is sort of a grey area. Cython aims to optimise access to builtin > types, so I find it a good thing to generate errors when users try to > redefine them. Obviously, this only makes sense once Cython actually > makes > the redeclarations completely redundant, which we haven't achieved > yet. > > We currently generate warnings when users redefine builtin types. I > think > that's ok for the time being. We should allow assignments to these re-defined types too, and let the user use an undocumented feature or shoot themselves in the foot if they want. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
