Skip to content

Commit 009ef29

Browse files
jdemeyerzooba
authored andcommitted
bpo-37913: document that __length_hint__ can return NotImplemented (GH-15383)
1 parent 17499d8 commit 009ef29

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Doc/reference/datamodel.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,8 +2155,10 @@ through the container; for mappings, :meth:`__iter__` should be the same as
21552155

21562156
Called to implement :func:`operator.length_hint`. Should return an estimated
21572157
length for the object (which may be greater or less than the actual length).
2158-
The length must be an integer ``>=`` 0. This method is purely an
2159-
optimization and is never required for correctness.
2158+
The length must be an integer ``>=`` 0. The return value may also be
2159+
*NotImplemented*, which is treated the same as if the ``__length_hint__``
2160+
method didn't exist at all. This method is purely an optimization and is
2161+
never required for correctness.
21602162

21612163
.. versionadded:: 3.4
21622164

0 commit comments

Comments
 (0)