Skip to content

Commit aa3b629

Browse files
authored
bpo-37913: document that __length_hint__ can return NotImplemented (GH-15383)
1 parent 4fbe0ee commit aa3b629

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Doc/reference/datamodel.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2142,7 +2142,9 @@ through the container; for mappings, :meth:`__iter__` should be the same as
21422142

21432143
Called to implement :func:`operator.length_hint`. Should return an estimated
21442144
length for the object (which may be greater or less than the actual length).
2145-
The length must be an integer ``>=`` 0. This method is purely an
2145+
The length must be an integer ``>=`` 0. The return value may also be
2146+
:const:`NotImplemented`, which is treated the same as if the
2147+
``__length_hint__`` method didn't exist at all. This method is purely an
21462148
optimization and is never required for correctness.
21472149

21482150
.. versionadded:: 3.4

0 commit comments

Comments
 (0)