On 12/03/2010 08:34 PM, Stefan Behnel wrote: > Robert Bradshaw, 03.12.2010 20:20: > >> On Fri, Dec 3, 2010 at 11:13 AM, Stefan Behnel wrote: >> >>> Dag Sverre Seljebotn, 03.12.2010 20:04: >>> >>>> I do have a much bigger problem with the naming here. I find >>>> this very little user-friendly: >>>> >>>> cdef complex x # x is Python object >>>> cdef double complex x # same precision but in C >>>> cdef float complex x # single precision in C >>>> >>>> I really do feel that "int" has kind of set the precedent here, and that >>>> if only "complex" is made available it should be as "double complex" or >>>> similar. >>>> >>> I would argue that the precendent is actually "float". We already (safely) >>> alias Python's "float" type to C's "double" type. Doing the same thing for >>> "complex" won't hurt as long as it keeps the same interface, would it? >>> >> If I write >> >> cdef float x >> >> there's no Python float object in the picture at all. >> > Come on, it's almost Christmas. Could we please all get back to > understanding each other? ;) > > I meant: we alias floating point values to C doubles and infer "double" > even if we know it's actually a Python float. When we do the same thing for > complex values and alias them to "C complex", we won't loose anything. >
Well, you don't loose anything with cdef double complex x = obj either, and it just seems a bit confusing to let "x.real = ..." have subtly different meaning. How about this: When you write x.real = 4 it actually "means" x = 4 + x.imag * 1j similar to how += works with immutable objects. That is: We allow it to happen, but it should be understood that no Python object is actually modified, but that the behaviour is that the "object" is replaced.. Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
