Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
85157cd8
Commit
85157cd8
authored
Apr 23, 2017
by
Serhiy Storchaka
Committed by
GitHub
Apr 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-15718: Document the upper bound constrain on the __len__ return value. (#1256)
parent
997a4ade
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
Doc/reference/datamodel.rst
Doc/reference/datamodel.rst
+9
-0
No files found.
Doc/reference/datamodel.rst
View file @
85157cd8
...
...
@@ -2011,6 +2011,14 @@ through the container; for mappings, :meth:`__iter__` should be the same as
:meth:`__bool__` method and whose :meth:`__len__` method returns zero is
considered to be false in a Boolean context.
.. impl-detail::
In CPython, the length is required to be at most :attr:`sys.maxsize`.
If the length is larger than :attr:`!sys.maxsize` some features (such as
:func:`len`) may raise :exc:`OverflowError`. To prevent raising
:exc:`!OverflowError` by truth value testing, an object must define a
:meth:`__bool__` method.
.. method:: object.__length_hint__(self)
...
...
@@ -2021,6 +2029,7 @@ through the container; for mappings, :meth:`__iter__` should be the same as
.. versionadded:: 3.4
.. note::
Slicing is done exclusively with the following three methods. A call like ::
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment