Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(6)

Side by Side Diff: Doc/library/collections.abc.rst

Issue 25958: Implicit ABCs have no means of "anti-registration"
Patch Set: Created 4 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Doc/reference/datamodel.rst » ('j') | Lib/test/test_binop.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`collections.abc` --- Abstract Base Classes for Containers 1 :mod:`collections.abc` --- Abstract Base Classes for Containers
2 =============================================================== 2 ===============================================================
3 3
4 .. module:: collections.abc 4 .. module:: collections.abc
5 :synopsis: Abstract base classes for containers 5 :synopsis: Abstract base classes for containers
6 .. moduleauthor:: Raymond Hettinger <python at rcn.com> 6 .. moduleauthor:: Raymond Hettinger <python at rcn.com>
7 .. sectionauthor:: Raymond Hettinger <python at rcn.com> 7 .. sectionauthor:: Raymond Hettinger <python at rcn.com>
8 8
9 .. versionadded:: 3.3 9 .. versionadded:: 3.3
10 Formerly, this module was part of the :mod:`collections` module. 10 Formerly, this module was part of the :mod:`collections` module.
(...skipping 24 matching lines...) Expand all
35 35
36 ========================== ====================== ======================= ====== ============================================== 36 ========================== ====================== ======================= ====== ==============================================
37 ABC Inherits from Abstract Methods Mixin Methods 37 ABC Inherits from Abstract Methods Mixin Methods
38 ========================== ====================== ======================= ====== ============================================== 38 ========================== ====================== ======================= ====== ==============================================
39 :class:`Container` ``__contains__`` 39 :class:`Container` ``__contains__``
40 :class:`Hashable` ``__hash__`` 40 :class:`Hashable` ``__hash__``
41 :class:`Iterable` ``__iter__`` 41 :class:`Iterable` ``__iter__``
42 :class:`Iterator` :class:`Iterable` ``__next__`` ``__it er__`` 42 :class:`Iterator` :class:`Iterable` ``__next__`` ``__it er__``
43 :class:`Generator` :class:`Iterator` ``send``, ``throw`` ``clos e``, ``__iter__``, ``__next__`` 43 :class:`Generator` :class:`Iterator` ``send``, ``throw`` ``clos e``, ``__iter__``, ``__next__``
44 :class:`Sized` ``__len__`` 44 :class:`Sized` ``__len__``
45 :class:`Reversible` :class:`Iterable` ``__reversed__``
45 :class:`Callable` ``__call__`` 46 :class:`Callable` ``__call__``
46 47
47 :class:`Sequence` :class:`Sized`, ``__getitem__``, ``__co ntains__``, ``__iter__``, ``__reversed__``, 48 :class:`Sequence` :class:`Sized`, ``__getitem__``, ``__co ntains__``, ``__iter__``, ``__reversed__``,
48 :class:`Iterable`, ``__len__`` ``inde x``, and ``count`` 49 :class:`Reversible`, ``__len__`` ``inde x``, and ``count``
49 :class:`Container` 50 :class:`Container`
50 51
51 :class:`MutableSequence` :class:`Sequence` ``__getitem__``, Inheri ted :class:`Sequence` methods and 52 :class:`MutableSequence` :class:`Sequence` ``__getitem__``, Inheri ted :class:`Sequence` methods and
52 ``__setitem__``, ``appe nd``, ``reverse``, ``extend``, ``pop``, 53 ``__setitem__``, ``appe nd``, ``reverse``, ``extend``, ``pop``,
53 ``__delitem__``, ``remo ve``, and ``__iadd__`` 54 ``__delitem__``, ``remo ve``, and ``__iadd__``
54 ``__len__``, 55 ``__len__``,
55 ``insert`` 56 ``insert``
56 57
57 :class:`Set` :class:`Sized`, ``__contains__``, ``__le __``, ``__lt__``, ``__eq__``, ``__ne__``, 58 :class:`Set` :class:`Sized`, ``__contains__``, ``__le __``, ``__lt__``, ``__eq__``, ``__ne__``,
58 :class:`Iterable`, ``__iter__``, ``__gt __``, ``__ge__``, ``__and__``, ``__or__``, 59 :class:`Iterable`, ``__iter__``, ``__gt __``, ``__ge__``, ``__and__``, ``__or__``,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 110
110 .. class:: Generator 111 .. class:: Generator
111 112
112 ABC for generator classes that implement the protocol defined in 113 ABC for generator classes that implement the protocol defined in
113 :pep:`342` that extends iterators with the :meth:`~generator.send`, 114 :pep:`342` that extends iterators with the :meth:`~generator.send`,
114 :meth:`~generator.throw` and :meth:`~generator.close` methods. 115 :meth:`~generator.throw` and :meth:`~generator.close` methods.
115 See also the definition of :term:`generator`. 116 See also the definition of :term:`generator`.
116 117
117 .. versionadded:: 3.5 118 .. versionadded:: 3.5
118 119
120 .. class:: Reversible
121
122 ABC for iterable classes that also provide the :meth:`__reversed__`
123 method.
124
125 .. versionadded:: 3.6
126
119 .. class:: Sequence 127 .. class:: Sequence
120 MutableSequence 128 MutableSequence
121 129
122 ABCs for read-only and mutable :term:`sequences <sequence>`. 130 ABCs for read-only and mutable :term:`sequences <sequence>`.
123 131
124 Implementation note: Some of the mixin methods, such as 132 Implementation note: Some of the mixin methods, such as
125 :meth:`__iter__`, :meth:`__reversed__` and :meth:`index`, make 133 :meth:`__iter__`, :meth:`__reversed__` and :meth:`index`, make
126 repeated calls to the underlying :meth:`__getitem__` method. 134 repeated calls to the underlying :meth:`__getitem__` method.
127 Consequently, if :meth:`__getitem__` is implemented with constant 135 Consequently, if :meth:`__getitem__` is implemented with constant
128 access speed, the mixin methods will have linear performance; 136 access speed, the mixin methods will have linear performance;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 are hashable or immutable. To add set hashability using mixins, 268 are hashable or immutable. To add set hashability using mixins,
261 inherit from both :meth:`Set` and :meth:`Hashable`, then define 269 inherit from both :meth:`Set` and :meth:`Hashable`, then define
262 ``__hash__ = Set._hash``. 270 ``__hash__ = Set._hash``.
263 271
264 .. seealso:: 272 .. seealso::
265 273
266 * `OrderedSet recipe <http://code.activestate.com/recipes/576694/>`_ for an 274 * `OrderedSet recipe <http://code.activestate.com/recipes/576694/>`_ for an
267 example built on :class:`MutableSet`. 275 example built on :class:`MutableSet`.
268 276
269 * For more about ABCs, see the :mod:`abc` module and :pep:`3119`. 277 * For more about ABCs, see the :mod:`abc` module and :pep:`3119`.
OLDNEW
« no previous file with comments | « no previous file | Doc/reference/datamodel.rst » ('j') | Lib/test/test_binop.py » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+