string.join is abysmally slow
Graham Guttocks
graham_guttocks at yahoo.co.nz
Sun Apr 15 22:25:57 EDT 2001
Pekka Pessi <Pekka.Pessi at nokia.com> wrote:
> If "|".join is slow, use it sparingly? The real problem
> seems to be that you are recreating the regexp about 238
> times or more, and then throwing the result away. Create
> the regexp once after the loop has completed.
Right. I don't know why I didn't notice this. Thanks. After moving
the string.join and re.compile outside the for loop, the same function
now processes 10,000 lines in under 15 seconds. Just a slight
improvement. :-)
Cheers,
Graham
_____________________________________________________________________________
http://movies.yahoo.com.au - Yahoo! Movies
- Now showing: Dude Where's My Car, The Wedding Planner, Traffic..
More information about the Python-list
mailing list