Stefan Behnel wrote: > Dag Sverre Seljebotn wrote: >> As for Python 2.6, it appears that we have the option to generate >> objects using the new buffer slots, but we can also generate objects >> without. Thoughts? >> >> Mine: At least as long as NumPy doesn't implement this for 2.6, I'd like >> to stay with emulation. If I get the time then perhaps a "dual-mode" >> where the slots are checked first, and if the object doesn't have the >> slots (i.e. the flags of the type is set to not supporting the new >> buffers) then emulation is used. > > If I understand correctly, you only refer to /getting/ the buffer of a > however implemented object, not about implementing the __getbuffer__() > method, right? So Cython implemented buffer objects would have their > __getbuffer__() in any case?
Not sure I understand this. The point anyway is that Cython currently does not fill the getbuffer slot on Py2.6. However, if we added Py_TPFLAGS_HAVE_NEWBUFFER to the type flags it seems we could do this, right? (I don't know much about these things so I'll have to listen to you here.) So the real question is whether we should change things so that bf_getbuffer is filled in under Py2.6; I suppose this calls for changing tp_flags on the classes which has __getbuffer__ or __releasebuffer__ implemented. (And then I will continue to also support emulation for object which don't have Py_TPFLAGS_HAVE_NEWBUFFER, in case libraries are simply recompiled for 2.6). > I don't see why we shouldn't support getting the buffer of /any/ object > that support the buffer protocol, be it in 2.6 or 3.0, instead of just > special casing NumPy. I do agree, however, that this is not a short-term > requirement. I think a dual-mode of NumPy special casing and generic > buffer support would be the best solution. The code for both is there > anyway, right? NumPy isn't special cased as such, it is an emulation mechanism by putting __getbuffer__ in numpy.pxd (and any other pxd). Comes close though. But the point is that no Cython classes support the buffer protocol under 2.6 in current Cython. -- Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
