diff options
author | Jelle Zijlstra <jelle.zijlstra@gmail.com> | 2023-05-04 14:59:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 14:59:46 (GMT) |
commit | 04f673327530f47f002e784459037231de478412 (patch) | |
tree | 56b29e35a1147b9655b5f4b4337f8a2f905b0e3f /Lib/_collections_abc.py | |
parent | b17d32c1142d16a5fea0c95bce185bf9be696491 (diff) | |
download | cpython-04f673327530f47f002e784459037231de478412.zip cpython-04f673327530f47f002e784459037231de478412.tar.gz cpython-04f673327530f47f002e784459037231de478412.tar.bz2 |
gh-102500: Implement PEP 688 (#102521)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Lib/_collections_abc.py')
-rw-r--r-- | Lib/_collections_abc.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py index 9d7724c..2117190 100644 --- a/Lib/_collections_abc.py +++ b/Lib/_collections_abc.py @@ -49,7 +49,7 @@ __all__ = ["Awaitable", "Coroutine", "Mapping", "MutableMapping", "MappingView", "KeysView", "ItemsView", "ValuesView", "Sequence", "MutableSequence", - "ByteString", + "ByteString", "Buffer", ] # This module has been renamed from collections.abc to _collections_abc to @@ -439,6 +439,21 @@ class Collection(Sized, Iterable, Container): return NotImplemented +class Buffer(metaclass=ABCMeta): + + __slots__ = () + + @abstractmethod + def __buffer__(self, flags: int, /) -> memoryview: + raise NotImplementedError + + @classmethod + def __subclasshook__(cls, C): + if cls is Buffer: + return _check_methods(C, "__buffer__") + return NotImplemented + + class _CallableGenericAlias(GenericAlias): """ Represent `Callable[argtypes, resulttype]`. |