On Thu, Mar 12, 2009 at 11:34 PM, Robert Kern firstname.lastname@example.org wrote:
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).
Without going into the whole pep 225 discussion, would it make sense for this particular case only, to consider instead a new %% operator? It could be the partner to the (/,//) pair that provide Python/C semantics for division, perhaps. That way, we'd know that the division-like operators come in 2 variants. We already know that the moment we do
that thing will not behave like a python int (e.g., its overflow behavior becomes constrained to what happens inside of a finite bit-width, instead of having Python's auto-growth into arbitrary length ints). So it seems acceptable to me that once I cdef integer variables, I'll need to keep the C/Python semantics in mind for / and %, and having pairs (/,//), (%,%%) of operators to access each type of behavior sounds reasonable to me.
Just a thought.