On 12/03/2010 08:05 PM, Stefan Behnel wrote: > Robert Bradshaw, 03.12.2010 19:57: > >> On Fri, Dec 3, 2010 at 10:53 AM, Stefan Behnel wrote: >> >>> Lisandro Dalcin, 03.12.2010 19:39: >>> >>>> On 3 December 2010 15:10, Stefan Behnel wrote: >>>> >>>>> I just implemented C access to the fields of CPython's builtin types like >>>>> this: >>>>> >>>>> cdef complex c = 1+2j >>>>> c.real, c.imag = 10, 20 >>>>> print (c.real, c.imag) >>>>> >>>>> >>> Given that these two fields carry the >>> same name as the Python visible attributes, this introduces behaviour that >>> diverges from CPython's own behaviour. Making these fields mutable means >>> that you will get an exception when you modify the field in CPython but a >>> straight value update after you compiled your code. >>> >> Of course we have exactly the same asymmetry for the read-only >> attributes of typed cdef classes. >> > Sure. But I think it's a difference if you allow users to change the values > of their own types, or if you allow them to accidentally change the value > of an internal type of the CPython runtime. >
+1. If we end up with stuff like this it's going to be a major pain for users: >>> x = 1 + 2j >>> f(x) >>> print x (300 + 4j) Dag Sverre _______________________________________________ Cython-dev mailing list Cython-dev@codespeak.net http://codespeak.net/mailman/listinfo/cython-dev