Old Buffer Protocol¶
3.0 版後已棄用.
These functions were part of the 「old buffer protocol」 API in Python 2. In Python 3, this protocol doesn’t exist anymore but the functions are still exposed to ease porting 2.x code. They act as a compatibility wrapper around the new buffer protocol, but they don’t give you control over the lifetime of the resources acquired when a buffer is exported.
Therefore, it is recommended that you call :cfunc:`PyObject_GetBuffer`
(or the y*
or w*
format codes with the
:cfunc:`PyArg_ParseTuple` family of functions) to get a buffer view over
an object, and :cfunc:`PyBuffer_Release` when the buffer view can be released.