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.