question about speed of sequential string replacement vs regex or

MRAB python at
Wed Sep 28 19:11:33 CEST 2011

On 28/09/2011 18:00, Willem wrote:
> Xah Lee wrote:
> ) 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.
> In Perl, it would be applicable.  You see, in Perl, you can call a function
> in the replacement of the regex substitution, which can then look up the
> html entity and return the wanted unicode literal.
> I think you can do that in some other languages as well.
Including Python...

More information about the Python-list mailing list