[issue41860] random.choices() raises "int too large" error while random.randint does not
Heng Sun
report at bugs.python.org
Fri Sep 25 01:14:18 EDT 2020
New submission from Heng Sun <sunheng at hotmail.com>:
If I run this one line of code:
random.choices(range(2**100), k=5)
I would get error:
OverflowError: Python int too large to convert to C ssize_t
But I can run equivalent line to achieve this without error:
[random.randint(0, 2**100-1) for j in range(5)]
With the understanding of the issue coming from len(), ref https://bugs.python.org/issue12159, I still think random.choices() should be able to handle large integers.
----------
components: Library (Lib)
messages: 377480
nosy: mathtester
priority: normal
severity: normal
status: open
title: random.choices() raises "int too large" error while random.randint does not
type: enhancement
versions: Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41860>
_______________________________________
More information about the Python-bugs-list
mailing list