On Fri, Dec 3, 2010 at 11:48 AM, Stefan Behnel <[email protected]> wrote:
> Dag Sverre Seljebotn, 03.12.2010 20:40:
>> 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.
>
> True. Maybe aliasing "complex" to "double complex" isn't a simple after all.
>
>
>> 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..
>
> Yuck! That's evil.

Yeah, I'm not a fan of that either.

My inclination would be to have complex be a simple alias for complex
double, and if one wants the Python object type one can cimport it
from cpython. -1 to having complex be a Python object in the builtin
namespace, or some hybrid object that's a complex double under the
hood but has the (incomplete?) semantics of a complex object. In this
respect the Python complex object type would be like the Python long,
float, and int types. They're rarely what the user actually wants
anyways.

- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to