]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-37913: document that __length_hint__ can return NotImplemented (GH-15383)
authorSteve Dower <steve.dower@python.org>
Tue, 10 Sep 2019 14:41:58 +0000 (15:41 +0100)
committerGitHub <noreply@github.com>
Tue, 10 Sep 2019 14:41:58 +0000 (15:41 +0100)
Doc/reference/datamodel.rst

index 962ec7e6c719de3bee61d59c2082a015fc1ccdfb..f5e23d85b9d8671160e9ef15c08aec638e1e256a 100644 (file)
@@ -2142,7 +2142,9 @@ through the container; for mappings, :meth:`__iter__` should be the same as
 
    Called to implement :func:`operator.length_hint`. Should return an estimated
    length for the object (which may be greater or less than the actual length).
-   The length must be an integer ``>=`` 0. This method is purely an
+   The length must be an integer ``>=`` 0. The return value may also be
+   :const:`NotImplemented`, which is treated the same as if the
+   ``__length_hint__`` method didn't exist at all. This method is purely an
    optimization and is never required for correctness.
 
    .. versionadded:: 3.4