[Cython] Semantics of cdef int division and %?
Stefan Behnel
stefan_ml at behnel.de
Thu Mar 12 11:00:42 CET 2009
William Stein wrote:
> On Thu, Mar 12, 2009 at 1:46 AM, Dag Sverre Seljebotn
> <dagss at student.matnat.uio.no> wrote:
>> Robert Bradshaw wrote:
>>> On Mar 12, 2009, at 12:26 AM, Carl Witty wrote:
>>>> How about a flag that generates runtime warnings on a%b and a//b
>>>> whenever a and b have different sign?
>>>
>>> This could be very useful for debugging things, but it implies
>>> there's a single, correct way that the % and // operators behave.
At least, there *must* be a single way that the % and // operators behave.
That's the only thing related to "correctness" in this debate.
> So I guess I prefer Python semantics for %, and an example in the
> documentation that explains how to get C semantics for % (i.e., via
> some macro or something).
... that, and by optimising away the adaptation on unsigned numbers (or at
least by checking that gcc does it for us).
> For those who view Cython as a way to write C code with a Python-like
> syntax, then C semantics would be preferable for %. I just don't see
> Cython that way, personally.
+1
Stefan
More information about the Cython-dev
mailing list