mirror of https://github.com/python/cpython
Close #18690: register memoryview with Sequence ABC
This commit is contained in:
parent
a0f169cde8
commit
45163ccce4
|
@ -2458,6 +2458,10 @@ copying.
|
|||
.. versionchanged:: 3.3
|
||||
One-dimensional memoryviews with formats 'B', 'b' or 'c' are now hashable.
|
||||
|
||||
.. versionchanged:: 3.4
|
||||
memoryview is now registered automatically with
|
||||
:class:`collections.abc.Sequence`
|
||||
|
||||
:class:`memoryview` has several methods:
|
||||
|
||||
.. method:: __eq__(exporter)
|
||||
|
|
|
@ -643,6 +643,7 @@ class Sequence(Sized, Iterable, Container):
|
|||
Sequence.register(tuple)
|
||||
Sequence.register(str)
|
||||
Sequence.register(range)
|
||||
Sequence.register(memoryview)
|
||||
|
||||
|
||||
class ByteString(Sequence):
|
||||
|
|
|
@ -782,6 +782,8 @@ class TestCollectionABCs(ABCTestCase):
|
|||
self.assertTrue(issubclass(sample, Sequence))
|
||||
self.assertIsInstance(range(10), Sequence)
|
||||
self.assertTrue(issubclass(range, Sequence))
|
||||
self.assertIsInstance(memoryview(b""), Sequence)
|
||||
self.assertTrue(issubclass(memoryview, Sequence))
|
||||
self.assertTrue(issubclass(str, Sequence))
|
||||
self.validate_abstract_methods(Sequence, '__contains__', '__iter__', '__len__',
|
||||
'__getitem__')
|
||||
|
|
Loading…
Reference in New Issue