Python idiom: Multiple search-and-replace

Randall Hopper aa8vb at yahoo.com
Wed Apr 12 12:00:12 EDT 2000


Fredrik Lundh:
 |Randall Hopper <aa8vb at yahoo.com> wrote:
 |> Is there a Python feature or standard library API that will get me less
 |> Python code spinning inside this loop?   re.multisub or equivalent? :-)
 |
 |haven't benchmarked it, but I suspect that this approach
 |is more efficient:
 |
 |<re.sub algorithm with replacement function>

Thanks!  It's much more efficient.  The 140 seconds original running time
was reduced to 11.6 seconds.  I can certainly live with that.

-- 
Randall Hopper
aa8vb at yahoo.com




More information about the Python-list mailing list