From: Steve Dower Date: Tue, 10 Sep 2019 14:31:26 +0000 (+0100) Subject: bpo-37913: document that __length_hint__ can return NotImplemented (GH-15383) X-Git-Tag: v3.8.0rc1~224 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ed99bb9ca68b37cfaec3629afa67d70289f3ffc7;p=thirdparty%2FPython%2Fcpython.git bpo-37913: document that __length_hint__ can return NotImplemented (GH-15383) --- diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 8813f57587f0..c6c6e4075039 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -2155,7 +2155,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