This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: `object`-backed `memoryview`'s `tolist` errors
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Dennis Sweeney, jakirkham
Priority: normal Keywords:

Created on 2020-07-06 21:19 by jakirkham, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg373175 - (view) Author: (jakirkham) Date: 2020-07-06 21:19
When working with an `object`-backed `memoryview`, it seems we are unable to coerce it to a `list`. This would be useful as it would provide a way to get the underlying `object`'s into something a bit easier to work with.

```
In [1]: import numpy                                                            

In [2]: a = numpy.array(["abc", "def", "ghi"], dtype=object)                    

In [3]: m = memoryview(a)                                                       

In [4]: m.tolist()                                                              
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-4-42400a31add8> in <module>
----> 1 m.tolist()

NotImplementedError: memoryview: format O not supported
```
msg402802 - (view) Author: Dennis Sweeney (Dennis Sweeney) * (Python committer) Date: 2021-09-28 19:42
Can you describe your use-case more? In particular, why use memoryview(a).tolist() instead of a.tolist()? Or some other numpy operations like a.flat or a.view()? Or even numpy.array(memoryview(a)) to recover a numpy array from a memoryview?

If this were implemented and stdlib memoryview objects supported some kind of object 'O' format, would list(memoryview(b"\0\0\0\0\0\0\0\0").cast('O')) dereference a null pointer and segfault?
History
Date User Action Args
2022-04-11 14:59:33adminsetgithub: 85395
2021-09-28 19:42:33Dennis Sweeneysetversions: - Python 3.6, Python 3.7, Python 3.8, Python 3.9, Python 3.10
nosy: + Dennis Sweeney

messages: + msg402802

components: + Interpreter Core
type: enhancement
2021-09-27 19:08:25jakirkhamsetversions: + Python 3.11
2020-07-06 21:19:56jakirkhamcreate