What if we would 'fix' the buffer interface? Extend the PyBufferProcs structure by new fields: typedef size_t (*getlargereadbufferproc)(PyObject *, void **); typedef size_t (*getlargewritebufferproc)(PyObject *, void **); typedef struct { getreadbufferproc bf_getreadbuffer; getwritebufferproc bf_getwritebuffer; getsegcountproc bf_getsegcount; getcharbufferproc bf_getcharbuffer; /* new fields */ getlargereadbufferproc bf_getlargereadbufferproc; getlargewritebufferproc bf_getlargewritebufferproc; } PyBufferProcs; The new fields are present if the Py_TPFLAGS_HAVE_GETLARGEBUFFER flag is set in the object's type. Py_TPFLAGS_HAVE_GETLARGEBUFFER implies the Py_TPFLAGS_HAVE_GETCHARBUFFER flag. These functions have the same semantics Scott describes: they must only be implemented by types only return addresses which are valid as long as the Python 'source' object is alive. Python strings, unicode strings, mmap objects, and maybe other types would expose the large buffer interface, but the array type would *not*. We could also change the name from 'large buffer interface' to something more sensible, currently I don't have a better name. Thomas
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4