[Cython] [cython] Stopgap solution for NumPy 1.7 API changes (#99)

Dag Sverre Seljebotn d.s.seljebotn at astro.uio.no
Wed Mar 28 16:40:47 CEST 2012

The idea really was that it would never stop working, but could in time be replaced by other features that would make this implementable in the pxd (like inlineable properties on extension types, typed tuples or lists).

Consider it speeding up the ndarray Python API, not providing any C API.

Note that even before this, the 'dims' field was renamed 'shape', because it is shape in the Python API.

Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Stefan Behnel <stefan_ml at behnel.de> wrote:

Dag Sverre Seljebotn, 21.03.2012 22:36:
> NumPy is starting to seriously deprecating access to the member fields
> in an ndarray (it was always frowned upon, but now it is starting to
> become enforced). To support the large body of Cython code out there
> accessing these fields (arr.shape[0] and so on), we special-case
> PyArrayObject in Cython, with special knowledge of the NumPy API.
> Ideally, we may introduce features in Cython in the future that allows
> specifying this kind of magic with syntax in pxd files, and then we can
> move away from special-casing NumPy.

Given the comments in this change, wouldn't it make sense to emit a visible
"this will eventually stop working" warning when user code runs into the
special casing hacks?

Just because the fields are convenient doesn't mean code should rely on
them being there when the NumPy folks say they shouldn't be accessible. As
I understand it, it's encouraged to use the accessor functions instead. If
that's what the NumPy developers want, users should just do that, should
they not?


cython-devel mailing list
cython-devel at python.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20120328/5b6850de/attachment.html>

More information about the cython-devel mailing list