Definition of PyBufferProcs in Python 2.7 when class implements PEP 3118 -


i in process of extending classes in our library (which supports python 2.7) support pep 3118, has been back-ported 2.7.

from documentation, need initialize tp_as_buffer field point pybufferprocs. documentation 2.7, however, the description of structure contains entries old buffer protocol. sources, gather pybufferprocs has additional entries new protocol (bf_getbuffer , bf_releasebuffer).

the questions remain:

  • do have special tell python these new entries valid?

  • do have fill in entries old protocol? (the documentation 2.7 says, example, bf_getsegcount may not null. entry shouldn't used if i'm supporting pep 3118.)

you can fill last 2 fields of pybufferprocs but have add py_tpflags_have_newbuffer flag tp_flags of types. special thing introduced in python2 make new protocol available old one.

i have no idea why isn't documented anywhere, can see used in definition of bytearray type python 2.7 (see here):

     &bytearray_as_buffer,               /* tp_as_buffer */     py_tpflags_default | py_tpflags_basetype |     py_tpflags_have_newbuffer,          /* tp_flags */ 

this content posted in comments, deserves answer.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -