On Mar 11, 2009, at 4:01 AM, Stefan Behnel wrote: > Dag Sverre Seljebotn wrote: >> Stefan Behnel wrote: >>> Dag Sverre Seljebotn wrote: >>>> I happen to routinely write (some complex integer expression)**2 in >>>> Python, and it is tedious to manually store the expression in a >>>> temporary >>>> etc. in Cython. >> >>> If you can come up with a sensible utility function that handles the >>> different C compile time and runtime overflow cases nicely, I'm >>> all for >>> it. >> >> So you are "+1 if I include an overflow check"? >> >> I was just thinking of letting it silently overflow, the way addition >> and multiplication already silently overflows. > > Hmm, yes, you are right. When a user writes > > cdef int tinyint = 2**2000 > > it's not Cython's fault if it overflows. > > So I guess I'm actually +1 for a fix that provides Python integer > power > semantics modulo C overflows/wrap-arounds. I guess that would be the > semantics with the lowest probability of surprise. > > Would you say that this makes sense as a utility function? > > I mean, we could always write out the bit-shifting code for a constant > exponent...
http://trac.cython.org/cython_trac/ticket/127 I only special-cased 0-3, the rest is generic (repeated squaring) code. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
