In-place array modification

Istvan Albert ialbert at
Mon Jul 19 01:18:51 CEST 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.


More information about the Python-list mailing list