In-place array modification
Istvan Albert
ialbert at mailblocks.com
Sun Jul 18 19:18:51 EDT 2004
umdehoon wrote:
> Say I have an array (Python array, not Numpy) that contains characters
>for i in range(n):
> s[i] = d[s[i]]
For large lists 'range' will affect the performance since it
creates another huge list. You might think about using xrange or
enumerate. With xrange I could replace 10 million bases in
20 seconds whereas I had to kill the test program using
range b/c it started gobbling up resources...
I suspected that psyco might do a good job of optimizing
this kind of looping. Indeed, the same job took less than 3
seconds with psyco enabled.
Istvan.
More information about the Python-list
mailing list