-
-
Notifications
You must be signed in to change notification settings - Fork 32k
memoryview lacks support for half floats #90751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
3.12
only security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-feature
A feature request or enhancement
Comments
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: >>> a = np.array([0.0, -1.5], np.float32())
>>> list(memoryview(a))
[0.0, -1.5]
>>> memoryview(a.tobytes()).cast('f').tolist()
[0.0, -1.5] 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 '@' |
corona10
added a commit
to corona10/cpython
that referenced
this issue
Sep 10, 2022
corona10
added a commit
to corona10/cpython
that referenced
this issue
Sep 10, 2022
pitrou
added a commit
to corona10/cpython
that referenced
this issue
Sep 10, 2022
pitrou
added a commit
that referenced
this issue
Sep 10, 2022
Co-authored-by: Antoine Pitrou <[email protected]>
@pitrou We can close this issue right? |
Ah, sorry, I forgot it. Yes, we can. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.12
only security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-feature
A feature request or enhancement
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: