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
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2022-01-31.15:29:00.019>labels= ['interpreter-core', 'type-feature', '3.11']
title='memoryview lacks support for half floats'updated_at=<Date2022-01-31.15:54:50.040>user='https://github.com/pitrou'
and float16, where support is minimal (casting forbidden, reading as Python objects unimplemented):
>>> a = np.array([0.0, -1.5], np.float16())
>>> list(memoryview(a))
Traceback (most recent call last):
File "<ipython-input-15-102982f8ac8e>", line 1, in <module>
list(memoryview(a))
NotImplementedError: memoryview: format e not supported
>>> memoryview(a.tobytes()).cast('e').tolist()
Traceback (most recent call last):
File "<ipython-input-25-78df215a7360>", line 1, in <module>
memoryview(a.tobytes()).cast('e').tolist()
ValueError: memoryview: destination format must be a native single character format prefixed with an optional '@'
Activity
pitrou commentedon Jan 31, 2022
The struct module has support for half-floats (the "e" format code) but support is not fully enabled in the memoryview object.
Let's contrast float32 (the "f" format code), which you can cast to, and read as Python objects:
and float16, where support is minimal (casting forbidden, reading as Python objects unimplemented):
pythongh-90751: memoryview supports half-float
pythongh-90751: memoryview supports half-float
Merge branch 'pythongh-90751' of https://github.com/corona10/cpython …
gh-90751: memoryview now supports half-float (#96738)
corona10 commentedon Sep 11, 2022
@pitrou We can close this issue right?
pitrou commentedon Sep 11, 2022
Ah, sorry, I forgot it. Yes, we can.