[Python-checkins] bpo-37913: document that __length_hint__ can return NotImplemented (GH-15383)
Steve Dower
webhook-mailer at python.org
Tue Sep 10 10:42:02 EDT 2019
https://github.com/python/cpython/commit/aa3b629a09bfcdf26cdfbbf7d6445ae333c0d44d
commit: aa3b629a09bfcdf26cdfbbf7d6445ae333c0d44d
branch: 3.7
author: Steve Dower <steve.dower at python.org>
committer: GitHub <noreply at github.com>
date: 2019-09-10T15:41:58+01:00
summary:
bpo-37913: document that __length_hint__ can return NotImplemented (GH-15383)
files:
M Doc/reference/datamodel.rst
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 962ec7e6c719..f5e23d85b9d8 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -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
More information about the Python-checkins
mailing list