Perfect your code
With built-in code review tools, GitHub makes it easy to raise the quality bar before you ship. Join the 40 million developers who've merged over 200 million pull requests.
Sign up for free See pricing for teams and enterprisesbpo-12159: document sys.maxsize limit in len() function reference #17934
Conversation
This comment has been minimized.
This comment has been minimized.
I think that this is a good addition to the documentation, but the example with |
@@ -892,6 +892,9 @@ are always available. They are listed here in alphabetical order. | |||
sequence (such as a string, bytes, tuple, list, or range) or a collection | |||
(such as a dictionary, set, or frozen set). | |||
|
|||
**CPython implementation detail:** ``len`` raises :class:`OverflowError` | |||
on inputs larger than :data:`sys.maxsize`, such as :class:`range`. |
This comment has been minimized.
This comment has been minimized.
vstinner
Jan 10, 2020
Member
on inputs larger than :data:`sys.maxsize`, such as :class:`range`. | |
on lengths larger than :data:`sys.maxsize`. |
I don't understand the "such as range()" part. len(range(5)) returns 5, it doesn't fail with overflow?
This comment has been minimized.
This comment has been minimized.
Zac-HD
Jan 11, 2020
Author
Contributor
I've clarified that this is for cases such as range(2 ** 64)
.
LGTM, but I would prefer to get a second review. @csabella @serhiy-storchaka @JulienPalard: What do you think of this len note? |
@@ -892,6 +892,10 @@ are always available. They are listed here in alphabetical order. | |||
sequence (such as a string, bytes, tuple, list, or range) or a collection | |||
(such as a dictionary, set, or frozen set). | |||
|
|||
**CPython implementation detail:** ``len`` raises :exc:`OverflowError` |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bedevere-bot
commented
Jan 12, 2020
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Zac-HD commentedJan 10, 2020
•
edited by bedevere-bot
See:
__len__
method but notlen()
, andhttps://bugs.python.org/issue12159