PEP 688: Making the buffer protocol accessible in Python

PyPy would love to see this adopted. As mentioned above, PyPy has a PyPy-specific __pypy_.buffereable base class with the __buffer__ method. The PyPy interpreter will look for that method on instances of classes that inherit from bufferable to implement memoryview(obj). This is what allows us to implement memoryview(ctypes.Array(...)) in pure python.

I removed the undocumented use of __buffer__ from numpy in order to clear up any confusion around this convention.

4 Likes