jeudi 21 janvier 2021

Python int too large to convert to C

I am running a simple piece of code to return me batch number of integers (without replacement) between 0 and 2**63.

from random import sample

batch = 1000
n = 63
rand_nos = sample(range(2**n), batch)

I get the error

Python int too large to convert to C ssize_t

I assume this has got to do with the random.sample function internally converting the length of the range to an int value. But I could not find any parameter that I could set, to ask the function to use a data type with larger range. How can I go about this? Thanks.




Aucun commentaire:

Enregistrer un commentaire