You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 2, 2021. It is now read-only.
# Example 2-21. Changing the value of an array item by poking one of its bytesimportarraynumbers=array.array('h', [-2, -1, 0, 1, 2])
memv=memoryview(numbers)
Gives me this error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-f1be3db9ba34> in <module>()
----> 1 memv = memoryview(numbers)
TypeError: cannot make memory view because object does not have the buffer interface
Based on research I did, this is a known limitation of python 2.7:
An array can only expose its contents via the old-style buffer interface. This limitation does not apply to Python 3, where memoryview objects can be constructed from arrays, too. Array elements may be multi-byte values.