[Numpy-discussion] __array__struct__: about using PyCapsule instead of PyCObject for Python 2.7

Charles R Harris charlesr.harris@gmail....
Wed Jun 30 13:08:24 CDT 2010

On Wed, Jun 30, 2010 at 10:57 AM, Lisandro Dalcin <dalcinl@gmail.com> wrote:

> On 30 June 2010 02:48, Charles R Harris <charlesr.harris@gmail.com> wrote:
> >
> >
> > On Tue, Jun 29, 2010 at 8:21 PM, Lisandro Dalcin <dalcinl@gmail.com>
> wrote:
> >>
> >> Do we really need this for NumPy 2? What about using the old PyCObject
> >> for all Py 2.x versions? If this is not done, perhaps NumPy 2 on top
> >> of Py 2.x should still accept the __array_struct__ being a PyCObject?
> >>
> >> As reference, Cython still uses PyCObject for Py<3.1
> >> http://hg.cython.org/cython-devel/rev/8a58f1544bd8#l1.33 .
> >>
> >
> > Blame the Python 2.7 developers, those suckers deprecated the PyCObject.
> >
> Oh! Sorry! Now I realize that!
Do I detect a touch of sarcasm?

> > Grrr... I didn't see the point, myself, I'm tempted to deprecate 2.7 just
> to
> > get even. There are some routines in the numpy/core/src includes that you
> > might want to copy, they will allow you to use a common interface for
> > PyCObject and PyCapsule if you need to do that.
> >
> I've already fixed my code for PyCapsule. What's not clear to me is
> how to build (i.e, use the old cobject or the new capsules)
> __array_struct__ across NumPy and Python versions combinations. Will
> NumPy 1.x series ever support Python 2.7? In such case, should I use
> cobjects or capsules?
> Still, I think NumPy should still accept cobjects from extension types
> on a Python 2.x runtime, the fix for this support is trival: accept
> cobjects in NpyCapsule_Check() and NpyCapsule_AsVoidPtr() for
That might work. The destructors are different between the two, but if you
just need access to the pointer things should be simpler. If you test it out
and put together a patch I don't see why it shouldn't be applied. If it
works. I'm a bit dubious about changing the check however.

> People can still live with PendingDeprecationWarning (remember, they
> are shown if explicitly requested with -W), and such warning is
> triggered when cobjects are created, not when they are accessed.
Yeah, but it is kind of ugly to have to deal with the warnings.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100630/57c996a7/attachment.html 

More information about the NumPy-Discussion mailing list