Help me choose a C++ compiler to work with Python

Alex Martelli aleax at aleax.it
Thu Sep 25 15:00:14 CEST 2003


Fernando Perez wrote:
   ...
>> e.g. generating billions (with a B) of random numbers with the
>> Mersenne Twister algorithm
> 
> Off the top of my head I don't know which rng RandomArray (part of
> Numeric) uses, but its speed is not that bad:
   ...
> The scaling is pretty linear, so for a billion terms you'd need about 2
> minutes.

Similar orders of magnitude for the built-in random number generator,
which IS a Mersenne Twister in Python 2.3 -- at least on my old trusty
Athlon box (no doubt today's CPU's would easily take 3 or 4 times less):

[alex at lancelot python2.3]$ python timeit.py \
> -s "from random import random"  \
> -s "times=[None]*1000" 
> "for x in times: random()"
1000 loops, best of 3: 380 usec per loop

380 microseconds for 1,000 calls to random.random(), and here, too,
very linear scaling, suggests about 380 seconds for a billion calls,
i.e., about 6 or 7 minutes, on this old machine.


Alex





More information about the Python-list mailing list