This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Zac Hatfield-Dodds
Recipients Zac Hatfield-Dodds
Date 2020-01-06.02:18:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1578277112.33.0.0446121238087.issue39227@roundup.psfhosted.org>
In-reply-to
Content
The value for `len` internally passes through an `ssize_t`, which means that it raises OverflowError for (very) large collections.

This is admittedly only possible with collections such as `range` that do not store all their elements in memory, but it would still be nice to have `len(range(n)) == n` without caveats.

This was found via a teaching example and is now tracked in my repo of property-based tests for CPython:
https://github.com/rsokl/Learning_Python/pull/125
https://github.com/Zac-HD/stdlib-property-tests/blob/bb46996ca4500381ba09a8cd430caaddd71910bc/tests.py#L28-L34

Related to https://bugs.python.org/issue26423, but it's still present in the development branches for 3.7, 3.8, and 3.9; and instead of a wrong result it's an error (which is better!).
History
Date User Action Args
2020-01-06 02:18:32Zac Hatfield-Doddssetrecipients: + Zac Hatfield-Dodds
2020-01-06 02:18:32Zac Hatfield-Doddssetmessageid: <1578277112.33.0.0446121238087.issue39227@roundup.psfhosted.org>
2020-01-06 02:18:32Zac Hatfield-Doddslinkissue39227 messages
2020-01-06 02:18:31Zac Hatfield-Doddscreate