Repository navigation
Clarify what memoryview is generic in #149488
Description
Activity
It is generic on the
__getitem__result:>>> memoryview(b'123')[0] 49 >>> memoryview(b'123').cast('c')[0] b'1'
We generally don't specify what the type is generic on, I am not sure that this is really needed? 🤔
We generally don't specify what the type is generic on, I am not sure that this is really needed?
It ought to be documented somewhere. Currently when a type is generic, the only way to figure out what the generic parameter represents is to read the typeshed stubs. That's not something we should expect users to do.
Documenting this in CPython is perhaps not ideal either, but I don't see a better place.
Maybe somewhere on typing.python.org?
I implemented the PEP-695 syntax in Sphinx because of Jelle wanted to document some generic classes (see sphinx-doc/sphinx#11438 and #104642) but not everything was included at that time (0511b6a). I think there was a discussion about adding the type parameters to the docs and we eventually decided not to. But I can't remember whether it was again decided differently or if we did something else
jonathandung commented
on May 24, 2026 on May 24, 2026 · Hidden as spamAuthorshow commentMore actions- moved this to Todo in Struct, memoryview and array issues 🏗️
on Jul 13, 2026 - moved this from Todo to Done in Struct, memoryview and array issues 🏗️
on Jul 13, 2026
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsTodo
- StatusShow more project fieldsDone
Documentation
The current documentation page for
memoryviewincludes a version-changed directive telling readers that the class started supporting subscripting in python 3.14. However, there is no mention as to what it is generic in. Maybe the answer was too obvious for the writer of the documentation, but it certainly isn't for a layman like me.