The future of buffer interfaces #48
jim-easterbrook
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The exiv2 classes
DataBuf
,PreviewImage
, andBasicIo
are all wrappers around potentially large blocks of memory. python-exiv2 gives each of these classes a "buffer interface", which allows many Python functions to access the data directly without making a copy.At some time in the future I'd like to use Python's "stable API" for python-exiv2 so that one binary wheel can work with multiple versions of Python. Unfortunately the buffer interface wasn't added to Python's stable API until Python 3.11, so any wheel compatible with Python < 3.11 won't be able to have buffer interfaces.
Another potential problem is that the next release of swig may not allow buffer interfaces in Python < 3.9. This is a consequence of changes in the way Python types are initialised. I've raised this as an issue in swig: swig/swig#3211
The three exiv2 classes also have methods that (in C++) return a pointer to the data. In Python these return a memoryview object, and that also has a buffer interface. It should be just as efficient to use these
data()
methods as to use the buffer interface, so I'd like to deprecate using buffer interfaces from now on.Beta Was this translation helpful? Give feedback.
All reactions