I want to generate random number between 0 to 3.8 million in python but it takes 1 second to generate such number, so is there any good way to generate it in a faster way ?
from random import randint
randomIndex = randint(1, 3800000)
print randomIndex
This is tacking 1 second, not every time, but sometimes so I want to optimize it so is there any solution ?
Also some good algorithm ?
If you want to speedup your code, you can try to use
numpypackage.On my system, random give me:
And numpy:
With a ~2.5x speedup.