bpo-37913: document that __length_hint__ can return NotImplemented (GH-15383)

This commit is contained in:
Steve Dower 2019-09-10 15:31:26 +01:00 committed by GitHub
parent 45bc3928e2
commit ed99bb9ca6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 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). 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. optimization and is never required for correctness.
.. versionadded:: 3.4 .. versionadded:: 3.4