Sturla Molden wrote:
>>> What does we expect
>>>
>>>    cdef float a
>>>
>>> to mean? Single or double precision?
>> "float" is a C type. You do the math.
> 
> float is also a Python type.

Correct. However, not in this context.


> Shouldn't we users expect it to have the semantics of a Python float?

Well, that's not how it works. A C float is not a Python float. That said,
I wouldn't mind seeing patches that add the support for fake Python methods
on the corresponding C types, so that you could do

    cdef float f = 0.5
    print f.is_integer()

But that would not change the semantics of a C float in C arithmetic, for
example. It would just be syntactic sugar.


> That is precisely the same argument you are using for int.

No, it's not. "cdef float f" defines f as a C float with C semantics. You
may want to read the distinction that I made in an earlier post regarding
the explicit semantics of a variable and the semantics of an operator,
which may or may not be explicit.


> Not keeping C and Python types apart only creates a big mess.

Not necessarily. It's all a matter of careful consideration and language
design.

Stefan

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

Reply via email to