[issue29816] Get rid of C limitation for shift count in right shift
Serhiy Storchaka
report at bugs.python.org
Wed Mar 15 05:19:13 EDT 2017
Serhiy Storchaka added the comment:
> If we change something, I suggest to be consistent with lshift. I expect a memory error on "1 << (1 << 1024)" (no unlimited loop before a global system collapse please ;-))
I agree that left shift should raise an ValueError rather than OverflowError for large negative shifts. But is hard to handle large positive shifts. `1 << count` consumes `count*2/15` bytes of memory. There is a gap between the maximal value of bits represented as Py_ssize_t (PY_SSIZE_T_MAX) and the number of bits of maximal Python int (PY_SSIZE_T_MAX*15/2). _PyLong_NumBits() starves from the same issue. I think an OverflowError is appropriate here for denoting the platform and implementation limitation.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29816>
_______________________________________
More information about the Python-bugs-list
mailing list