◐ Shell
clean mode source ↗

bpo-12159: document sys.maxsize limit in len() function reference by Zac-HD · Pull Request #17934 · python/cpython

@cool-RR

I think that this is a good addition to the documentation, but the example with range is weird. Maybe you mean that big ranges, such as range(10 ** 100) will be too big. That isn't clear from your text.

vstinner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've clarified that this is for cases such as range(2 ** 64).

vstinner

@vstinner vstinner changed the title BPO-12159: document sys.maxsize limit in function reference for len() bpo-12159: document sys.maxsize limit in len() function reference

Jan 11, 2020

vstinner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

csabella

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Since this has been brought up multiple times, I think it's best to document it, especially since __len__ had a note added in the past. Thanks for the patch, @Zac-HD!

csabella

@bedevere-bot

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@Zac-HD

I have made the requested changes; please review again

@bedevere-bot

Thanks for making the requested changes!

@csabella, @vstinner: please review the changes made to this pull request.

@Zac-HD Zac-HD deleted the document-len-overflow branch

January 12, 2020 10:33

shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request

Jan 31, 2020

@cool-RR cool-RR mannequin mentioned this pull request

Apr 29, 2022