[Cython] Semantics of cdef int division and %?
Stefan Behnel
stefan_ml at behnel.de
Wed Mar 11 14:36:11 CET 2009
Dag Sverre Seljebotn wrote:
> Lisandro Dalcin wrote:
>> Of course, I could live if Cython does this:
>>
>> - Python semantics for '%'
>> - C semantics for an all-new operator '%%'. Just thinking on what
>> Python has done with '//'
>>
> BTW I'm +0 on a new %%. As long as there is also a function in the
> cython module to do the same while having Python-compatible syntax.
I vote for being careful with new operators. If Python ever decides that
it needs a '%%' on its own for whatever reason, we'd better be in the
stdlib first and have a good eye on python-dev at that point.
I'm rather for considering "-1%16==-1" an odd corner case that's not worth
being the default in Cython (as you said, the idea is to come from Python
and step down into C at need). Having a special "cython.signed_mod()"
function seems enough to support it.
> And I'm definitely +1 on having "<unsigned>a % <unsigned>b" mean "a %% b".
Fair enough, but my guess is that the C compiler would do that for us.
Stefan
More information about the Cython-dev
mailing list