repeat itself is not slow, it's just that when it's used it iterates over it, in RPython (meaning it's not jit'd) which results in a dictionary lookup for the next() method at every iteration, which is slowish, list hits a special case so it doesn' thave that overhead.
Alex On Thu, Jul 7, 2011 at 5:30 PM, Romain Guillebert <romain...@gmail.com>wrote: > Hi > > When I change this line: > > primes[i*i:N+1:i] = repeat(False, len(primes[i*i:N+1:i])) > > into this : > > primes[i*i:N+1:i] = [False] * len(primes[i*i:N+1:i]) > > PyPy is much faster (but is still slower than CPython), so I would guess > that the repeat function is the one to blame. > > Cheers > Romain > > On Fri, Jul 08, 2011 at 02:03:20AM +0300, Alexander Petrov wrote: > > Hi. > > > > I'm new to PyPy and was trying to run some tests to see orders of > > speed improvement. > > > > Short script generating list of prime numbers using rather > > straightforward implementation of Eratosthene's sieve. > > Script: http://paste.pocoo.org/show/432727/ > > > > Typical results: http://paste.pocoo.org/show/432733/ > > (I thought that is due to absense of SSE2 on first computer, but I've > > rechecked on Intel(R) Xeon(R) CPU L5520 @ 2.27GHz with similar > > results). > > > > I'm getting that CPython is nearly 4-8 times faster than PyPy. > > Is it a bug in PyPy or what is wrong (may be "specific" to PyPy) in my > script? > > > > Alex. > > _______________________________________________ > > pypy-dev mailing list > > pypy-dev@python.org > > http://mail.python.org/mailman/listinfo/pypy-dev > _______________________________________________ > pypy-dev mailing list > pypy-dev@python.org > http://mail.python.org/mailman/listinfo/pypy-dev > -- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero
_______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev