Dag Sverre Seljebotn, 03.12.2009 10:52:
>> - Python's floating point type is double, so it should be perfectly 
>> safe to do
>>
>> cdef double f(): ...
>> x = f() # infer x as double
>>
>> By the same argument one might actually want to do
>>
>> cdef float f(): ...
>> x = f() # infer x as *double* -- because that's what Python would use

That's actually an orthogonal feature: aliasing Python's float type to C's
double type in general, including support for methods etc. Since 'double'
is immutable and has exactly the same value range as Python's float type,
this is something that can always be done safely. If I'm not mistaken, even
Python's operators behave exactly like the equivalent C operators here,
right? And numeric operations would always return a double, so even
operations on doubles that involve integers would run completely in C space.

Apart from a couple of further optimisations for methods and properties, I
think enabling type inference here would give us a rather warmly requested
feature.

Stefan

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

Reply via email to