New submission from Zac Hatfield-Dodds <zac.hatfield.do...@gmail.com>:
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!). ---------- components: Interpreter Core messages: 359394 nosy: Zac Hatfield-Dodds priority: normal severity: normal status: open title: OverflowError in len(range(2**63)) type: behavior versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39227> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com