Deleting specific characters from a string

Paul Rudin paul_rudin at scientia.com
Thu Jul 10 17:29:29 CEST 2003


>>>>> "Michael" == Michael Chermside <mcherm at mcherm.com> writes:

    > Paul Rudin writes:


    >> I'd expect it to be faster than your solution - particularly on
    >> large input (although I haven't actually tried).

    > Hmm... I doubt it. I'd expect the translate() version to be the
    > fastest, with multiple string.remove()'s being competative when
    > the number of different characters to be removed is small. RE's
    > are NOT renown for their speed when doing simple character
    > replacement, deletion or insertion on strings. 

My comparison was with one particular solution, not all solutions
mentioned. Still I was previosuly unaware of the existence of
translate... so thanks for mentioning it.


    > But _I_ haven't timed it either, so I'm going to shut up now.

Me too :-)




More information about the Python-list mailing list