Psycho question

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Wed Aug 6 23:33:14 CEST 2008


Erik Max Francis:
> If len(bytes) is large, you might want to use `xrange`, too.  `range`
> creates a list which is not really what you need.

That's right for Python, but Psyco uses normal loops in both cases,
you can time this code in the two situations:

def foo1(n):
    count = 0
    for i in range(n):
        count += 1
    print count

def foo2(n):
    count = 0
    for i in xrange(n):
        count += 1
    print count

import psyco; psyco.full()
N = 100000000
#foo1(N)
foo2(N)

Bye,
bearophile



More information about the Python-list mailing list