[Cython] Semantics of cdef int division and %?
Stefan Behnel
stefan_ml at behnel.de
Mon Mar 16 19:02:47 CET 2009
Sturla Molden wrote:
>> There is a very clear distinction between all types, including Python
>> types
>> and C types. The internals are not always simple, but the syntax is and
>> the semantics tries to be, which is the thing that matters.
>
> You are adding Python syntax to some but not all C types
I assume you meant semantics here.
> with the
> argument that you are trying to make Cython an optionally statically typed
> Python.
It's actually more complex than that. There are constraints that come from
the compatibility to Py2.x and Py3, from language features in C and Python,
from different C standards and compilers, ...
Once all of that's been considered, the remaining design decisions are
rarely black-or-white. This very thread is just one example.
> So 'cdef int' gives the behaviour of a Python int, whilst 'cdef
> float' gives the behaviour of a C float.
This is wrong, please read what I posted already.
>> This discussion is not about right or wrong, it's about good semantics
>> that matches the expectations that users have of the language.
>
> What does we expect
>
> cdef float a
>
> to mean? Single or double precision?
"float" is a C type. You do the math.
Stefan
More information about the Cython-dev
mailing list