question about speed of sequential string replacement vs regex or

Xah Lee xahlee at gmail.com
Wed Sep 28 08:28:01 EDT 2011


On Sep 28, 3:57 am, mer... at stonehenge.com (Randal L. Schwartz) wrote:
> >>>>> "Xah" == Xah Lee <xah... at gmail.com> writes:
>
> Xah> curious question.
> Xah> suppose you have 300 different strings and they need all be replaced
> Xah> to say "aaa".
>
> And then suppose this isn't the *real* question, but one entirely of
> Fiction by Xah Lee.
>
> How helpful do you want to be?

it's a interesting question anyway.

the question originally came from when i was coding elisp of a
function that changes html entities to unicode char literal. The
problem is slightly complicated, involving a few questions about speed
in emacs. e.g. string vs buffer, and much more... i spent several
hours on this but it's probably too boring to detail (but i'll do so
if anyone wishes). But anyway, while digging these questions that's
not clear in my mind, i thought of why not generate a regex or
construct and do it in one shot, and wondered if that'd be faster. But
afterwards, i realized this wouldn't be applicable to my problem
because for my problem each string needs to be changed to a unique
string, not all to the same string.

 Xah



More information about the Python-list mailing list