Another question
Donald Beaudry
donb at init.com
Mon Apr 17 17:20:31 EDT 2000
jimsp <jimsp at ichips.intel.com> wrote:
> How about
>
> >>> import random
> >>> x = [0]*1000000
> >>> y = map(lambda x: random.randint(1,10), x)
Hmm.... believe it or not that one is much closer to what I meant to
type as my 'or better' example, than the rubbish that I did type ;)
But, this one beats it (and I tested it this time ;).
import random
y = map(lambda x, randint=random.randint: randint(1,10), xrange(100000))
and this one is better still (at least on my machine):
def do_it():
from random import randint
r = [0,] * 100000
for i in xrange(100000):
r[i] = randint(1,10)
do_it()
--
Donald Beaudry Ab Initio Software Corp.
201 Spring Street
donb at init.com Lexington, MA 02421
...Will hack for sushi...
More information about the Python-list
mailing list