[Numpy-discussion] Poll: Semantics for % in Cython
Fri Mar 13 01:34:02 CDT 2009
On Fri, Mar 13, 2009 at 01:41, Dag Sverre Seljebotn
> Robert Kern wrote:
>> That may be part of the confusion. The expression "-1%5" has no
>> variables. Perhaps Dag can clarify what he is asking about:
>> # Constants? (No one uses just constants in expressions,
>> # really, but consistency with the other choices will
>> # affect this.)
>> -1 % 5
>> # Explicitly declared C types?
>> cdef long i, j, k
>> i = -1
>> j = 5
>> k = i % j
> This one is what I'm really asking about.
My opinion on this is that C semantics have been explicitly requested,
so they should be used.
One possibility (that may be opening a can of worms) is to have two
sets of operators, one that does "native" semantics (C for cdef longs,
Python for Python ints) and one that does Python semantics even on
cdef longs. I leave it to you to decide which one gets blessed with
"%" and which has to use the alternate ("~%"? there's a whole PEP
sitting around which goes over various options).
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion