Message361821
Right now, the behavior is:
>>> import numpy as np
>>> arr_0d = np.array(42)
>>> mem_0d = memoryview(arr_0d)
>>> len(mem_0d)
1
>>> mem_0d[0]
TypeError: invalid indexing of 0-dim memory
It seems bizarre to have this object pretend to be a sequence when you ask for its length, yet not behave like one when you actually try to use this length. I'd suggest cpython should behave like numpy here, and fail:
>>> len(arr_0d)
TypeError: len() of unsized object
Perhaps `TypeError: cannot get length of 0-dim memory` would be more appropriate as a message.
---
Wasn't sure how to classify this, feel free to reclassify |
|
Date |
User |
Action |
Args |
2020-02-11 15:42:52 | Eric Wieser | set | recipients:
+ Eric Wieser, skrah |
2020-02-11 15:42:52 | Eric Wieser | set | messageid: <1581435772.39.0.91175671687.issue39610@roundup.psfhosted.org> |
2020-02-11 15:42:52 | Eric Wieser | link | issue39610 messages |
2020-02-11 15:42:52 | Eric Wieser | create | |
|