Python idiom: Multiple search-and-replace
effbot at telia.com
Wed Apr 12 18:25:32 CEST 2000
Randall Hopper <aa8vb at yahoo.com> wrote:
> Thanks! It's much more efficient. The 140 seconds original running time
> was reduced to 11.6 seconds. I can certainly live with that.
thought so ;-)
while you're at it, try replacing the original readline loop with:
lines = fp.readlines(BUFFERSIZE)
if not lines:
lines = string.join(lines, "")
lines = re.sub(...)
where BUFFERSIZE is 1000000 or so...
More information about the Python-list