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

Stefan Behnel stefan_ml at behnel.de
Wed Mar 28 09:11:39 CEST 2012

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?


More information about the cython-devel mailing list