[Cython] Please vote: wraparound directive
Kurt Smith
kwmsmith at gmail.com
Fri May 1 15:50:01 CEST 2009
On Fri, May 1, 2009 at 7:28 AM, Dag Sverre Seljebotn
<dagss at student.matnat.uio.no> wrote:
> A new directive which allows Cython to assume that integers passed to []
> are not negative.
>
> Currently buffers have the negative_indices option:
>
> object[int, negative_indices=False] arr = ...
>
> but this can be cumbersome and less flexible. The rationale for not
> doing this in the first place was that it changes semantics during
> normal running rather than under exceptional circumstances, but now
> @cdivision has crossed that line anyway.
+1 for me.
Since directives can be module, function or block scoped they're
pretty flexible, and it makes it clear & explicit that different
semantics are going on.
The current state allows the use of two different negative_indices
type buffers in the same expression:
arr_neg[a,b] = arr_neg[a,b] + arr_no_neg[abs(a), abs(b)]
While that would be impossible with the proposed directive. I can't
easily think of cases when I'd like to mix negative & non_negative
indexing in the same expression, or when I couldn't just revert to
regular indexing for these cases when required -- presumably I'm
giving the arr_no_neg 'negative_indices=False' since I want to speed
things up, and I should do the same for the other arrays.
I like that it lifts the semantics out of the individual arrays and
puts it in a directive.
Kurt
>
> Also note that this could potentially apply to typed lists and tuples as
> well, if there's a benefit.
>
> --
> Dag Sverre
> _______________________________________________
> Cython-dev mailing list
> Cython-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/cython-dev
More information about the Cython-dev
mailing list