question about speed of sequential string replacement vs regex or
willem at toad.stack.nl
Wed Sep 28 13:00:51 EDT 2011
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.
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
More information about the Python-list