[pypy-issue] [issue813] Random is slower than cpython

Ismael tracker at bugs.pypy.org
Fri Jul 29 00:16:44 CEST 2011


New submission from Ismael <ismaelgfk at gmail.com>:

Random.random() is aprox. 10 times slower on PyPy, random.randint() is 2 times
slower.

Code:

from time import time
import random

ini = time()
for i in xrange(1000):
    random.random()
fin = time()
print "Random.random() ", fin - ini

ini = time()
for i in xrange(1000):
    random.randint(0, 10)
fin = time()
print "Random.randint() ", fin - ini

Timings:

Python 2.6.6:
ismael at chaos:~/workspace/testsum/src$ python test.py 
Random.random()  0.000263929367065
Random.randint()  0.00369191169739

Python 2.7:
ismael at chaos:~/workspace/testsum/src$ python2.7 test.py 
Random.random()  0.000288963317871
Random.randint()  0.00278496742249

PyPy trunk:
ismael at chaos:~/workspace/testsum/src$
~/pypy/pypylatest/pypy-c-jit-46033-811906ece2d8-linux64/bin/pypy test.py 
Random.random()  0.00127387046814
Random.randint()  0.00587606430054

PyPy 1.5:
ismael at chaos:~/workspace/testsum/src$ ~/pypy/bin/pypy test.py 
Random.random()  0.00275802612305
Random.randint()  0.00753998756409

----------
messages: 2881
nosy: Ismael, pypy-issue
priority: bug
status: unread
title: Random is slower than cpython

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue813>
________________________________________


More information about the pypy-issue mailing list