Alexander Belopolsky
2016-03-27 21:00:51 UTC
In the following session a numpy array is created from an stdlib array:
In [1]: import array
In [2]: base = array.array('i', [1, 2])
In [3]: a = np.asarray(base)
In [4]: a.base
Out[4]: <memory at 0x7fb80383e8c8>
In [5]: a.base.obj
Out[5]: array('i', [1, 2])
In [6]: a.base.obj is base
Out[6]: True
Why can't a.base be base? What is the need for the intermediate memoryview
object?
In [1]: import array
In [2]: base = array.array('i', [1, 2])
In [3]: a = np.asarray(base)
In [4]: a.base
Out[4]: <memory at 0x7fb80383e8c8>
In [5]: a.base.obj
Out[5]: array('i', [1, 2])
In [6]: a.base.obj is base
Out[6]: True
Why can't a.base be base? What is the need for the intermediate memoryview
object?