On Mar 11, 2009, at 2:49 AM, Dag Sverre Seljebotn 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.
>>
>
> To be clear, I'm in favour of overflow checks, I just think they in  
> that
> case should apply in *all* situations, not simply in this one  
> operator.
> Otherwise Cython will be inconsistent and it makes the language harder
> to learn.
>
> So I'm thinking this:
> 1) Add integer ** without overflow check
> 2) Add overflowcheck compiler directive, similar to the nonecheck
> directive, which checks for overflows in /all/ situations (which
> defaults to off though)

+1

We should special constant case base 2 (or perhaps base power of 2)  
and constant exponent up to, say, 5 or so.

- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to