0
0
mirror of https://github.com/python/cpython.git synced 2024-11-21 12:59:38 +01:00

gh-126012: Add __class_getitem__ to memoryview (#126013)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
Brian Schubert 2024-10-27 06:36:03 -04:00 committed by GitHub
parent dad3453129
commit dc76a4ad3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 1 deletions

View File

@ -3889,6 +3889,9 @@ copying.
.. versionchanged:: 3.5
memoryviews can now be indexed with tuple of integers.
.. versionchanged:: next
memoryview is now a :term:`generic type`.
:class:`memoryview` has several methods:
.. method:: __eq__(exporter)

View File

@ -194,6 +194,10 @@ Other language changes
:mod:`copyable <copy>`.
(Contributed by Serhiy Storchaka in :gh:`125767`.)
* The :class:`memoryview` type now supports subscription,
making it a :term:`generic type`.
(Contributed by Brian Schubert in :gh:`126012`.)
New modules
===========

View File

@ -100,7 +100,7 @@ _UNPACKED_TUPLES = [
class BaseTest(unittest.TestCase):
"""Test basics."""
generic_types = [type, tuple, list, dict, set, frozenset, enumerate,
generic_types = [type, tuple, list, dict, set, frozenset, enumerate, memoryview,
defaultdict, deque,
SequenceMatcher,
dircmp,

View File

@ -0,0 +1,2 @@
The :class:`memoryview` type now supports subscription, making it a
:term:`generic type`.

View File

@ -3286,6 +3286,7 @@ static PyMethodDef memory_methods[] = {
MEMORYVIEW__FROM_FLAGS_METHODDEF
{"__enter__", memory_enter, METH_NOARGS, NULL},
{"__exit__", memory_exit, METH_VARARGS, memory_exit_doc},
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
{NULL, NULL}
};