[Cython] Upcoming cython/numpy breakage with stride checking

Nathaniel Smith njs at pobox.com
Mon Apr 8 20:10:27 CEST 2013


On Mon, Apr 8, 2013 at 7:42 AM, Dag Sverre Seljebotn
<d.s.seljebotn at astro.uio.no> wrote:
> I guess you have changed your implementation of PEP 3118 too slightly on the NumPy side? Is this undefined in the PEP or are you now not in strict adherence to it?

I just checked, and PEP 3118 just says that if a {C,F,ANY}_CONTIGUOUS
buffer is requested, then that should be provided, and the strides
array should contain something valid (not be NULL). They don't define
any algorithm for matching {C,F,ANY}_CONTIGUOUS to particular strides.
My interpretation would be, we're satisfying this just fine so long as
our memory layout actually does match what was requested (i.e., the
strides are not needed).

Obviously Cython goes above and beyond in checking the strides -- if
you just *trusted* us then it would all work out ;-). If there's other
code that's similarly picky then it might be useful for us to take
some special effort of "canonicalize" the strides when exporting a PEP
3118 buffer, like Sebastian says, but eh. This is arguably just
papering over buggy code, and such code may or may not exist... (Or is
it only the PEP 3118 buffer strides that Cython actually checks? If
there's a simple hack we can do that will let us avoid forcing
everyone to rebuild their Cython modules then it will make this
transition significantly easier...)

-n


More information about the cython-devel mailing list