question about speed of sequential string replacement vs regex or

Chris Angelico rosuav at gmail.com
Wed Sep 28 12:04:43 CEST 2011


On Wed, Sep 28, 2011 at 7:28 PM, Xah Lee <xahlee at gmail.com> wrote:
> suppose you have 300 different strings and they need all be replaced
> to say "aaa".
>
> is it faster to replace each one sequentially

Before you ask "is it faster", you need to first be sure it's correct.
I would recommend doing all the replaces in a single function call to
avoid risk of overlaps or other issues causing problems.

ChrisA



More information about the Python-list mailing list