[issue10889] Fix range slicing and indexing to handle lengths sys.maxsize
New submission from Nick Coghlan ncogh...@gmail.com: Enhancement to range to correctly handle indexing and slicing when len(x) raises OverflowError. Note that this enables correct calculation of the length of such ranges via: def _range_len(x): try: length = len(x) except OverflowError: step = x[1] - x[0] length = 1 + ((x[-1] - x[0]) // step) return length -- assignee: ncoghlan messages: 126017 nosy: ncoghlan priority: normal severity: normal status: open title: Fix range slicing and indexing to handle lengths sys.maxsize ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10889] Fix range slicing and indexing to handle lengths sys.maxsize
Nick Coghlan ncogh...@gmail.com added the comment: Having started work on this, the code changes are probably too significant to consider adding it to 3.2 at this late stage. Writing my own slice interpretation support which avoids the ssize_t limit is an interesting exercise :) -- versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10889] Fix range slicing and indexing to handle lengths sys.maxsize
Nick Coghlan ncogh...@gmail.com added the comment: Attached patch moves range indexing and slicing over to PyLong and updates the tests accordingly. Georg, I think this really makes the large range story far more usable - if you're OK with it, I would like to check it in this week so it lands in 3.2. -- assignee: ncoghlan - georg.brandl keywords: +patch nosy: +georg.brandl versions: +Python 3.2 -Python 3.3 Added file: http://bugs.python.org/file20355/issue10889_range_subscripts.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10889] Fix range slicing and indexing to handle lengths sys.maxsize
Nick Coghlan ncogh...@gmail.com added the comment: Oh, and to explain my negative comment from earlier: that was my reaction when I realised I also needed to write PyLong versions of _PyEval_SliceIndex and PySlice_GetIndicesEx to make range slicing with large integers work properly. As it turned out, the end result wasn't as scary as I initially feared (while compute_slice_indices is quite long, most of that is just the verbosity of PyLong arithmetic). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10889] Fix range slicing and indexing to handle lengths sys.maxsize
Georg Brandl ge...@python.org added the comment: It's a moderate chunk of code, but lots of new tests... I'd say go for it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10889] Fix range slicing and indexing to handle lengths sys.maxsize
Nick Coghlan ncogh...@gmail.com added the comment: Committed as r87948. I added a few large_range tests to those in the patch. I checked that IndexError is raised when appropriate, as well as a specific test for the combination of a large range with a large negative step. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10889] Fix range slicing and indexing to handle lengths sys.maxsize
Changes by Nick Coghlan ncogh...@gmail.com: -- resolution: - accepted stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10889] Fix range slicing and indexing to handle lengths sys.maxsize
Changes by Mark Dickinson dicki...@gmail.com: -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com