On boundscheck, I'm thinking that it means "make the assumption that this code 
will not raise an IndexError". That's it.

(And I think it should apply to lists and tuples as well if possible.

(One could add a more fine-grained buffer_bounds_check too then, of course. Or 
"boundscheck = all", "boundscheck=None", "boundscheck = list,buffer"). But 
let's leave that for now, we can be backwards compatible later.

Dag Sverre Seljebotn
-----Original Message-----
From: Robert Bradshaw <[EMAIL PROTECTED]>
Date: Sunday, Aug 17, 2008 10:11 am
Subject: Re: [Cython] Boundchecking question
To: [EMAIL PROTECTED]: [email protected]

On Aug 17, 2008, at 12:23 AM, Dag Sverre Seljebotn wrote:
>
>> I'm not sure what you mean -- a negative bound is only checked for  
> once per dimension. I.e. Positive ints are only checked for  
> negativity once per dim.
>
>> (Remember that one must also check for the negative bound, i.e. -n,  
> but this is only done for negative numbers).
>
>I am talking about the case where bounds checking is turned off, and  
>"once per dimension" is relatively expensive. Even when it predicts  
>correctly it still does the test. I've got some code using 2D buffers  
>in the inner loop. Here's the timings:
>
>CPU time: 1.50 s,  Wall time: 1.52 s -- standard buffers
>CPU time: 1.00 s,  Wall time: 1.01 s -- boundscheck=False
>CPU time: 0.77 s,  Wall time: 0.78 s -- unsigned indices
>
>(Note, I'm not even going to time the non-buffer version, but its  
>certainly on the order of minutes--buffers are awsome!).
>
>> There is potential for optimizing the exceptional case when bounds  
> are off (but the code would be a little less clean and exceptional  
> cases are just that).
>
>> Could you perhaps post some C code modified as you suggest?
>
>Essentially it's the C code one gets if one manually casts the  
>indices to unsigned ints. It's just that that makes the code  
>significantly uglier.
>
>> Finally, if what you propose is a change in semantics, then this  
> already met resistance on the numpy list. Perhaps a buffer-unsigned- 
> indices-only compiler directive.
>
>I was thinking of the case that bounds checking is turned off, in  
>which case we already have a change in semantics, right? I could see  
>this being a distinct compiler directive though, that's probably the  
>way to go.
>
>> (However I think that it is possible to write your code using  
> unsigneds so that you use unsigned everywhere instead of signed,  
> and then this comes automatically...)
>
>> I don't care too much about constants, they're not likely to be  
> used in performance critical code I think.
>
>Constants will be optimized away. But if I write "i+1" where i is an  
>unsigned int, the result is still signed.
>
>>
> Dag Sverre Seljebotn
>
>> -----Original Message-----
> From: Robert Bradshaw <[EMAIL PROTECTED]>
> Date: Sunday, Aug 17, 2008 6:55 am
> Subject: [Cython] Boundchecking question
> To: Cython-dev <[email protected]>Reply-To: cython- 
> [EMAIL PROTECTED]
>
>> I've been playing with the (very cool!) buffer stuff Dag did getting
>> ready for

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

Reply via email to