Deleting specific characters from a string
Jeff Hinrichs
jlh at cox.net
Thu Jul 10 23:18:53 EDT 2003
First off, (holding hat in hand), I reread the profile module and then set
my profiler up correctly with the proper bias setting. Things have changed
but only slightly. Duncan Booth's maketrans/translate is edging out the
stringReplace for first place in speed. Looks to be with in the margin of
error for timing on my windows platform.
I am rerunning the entire test suite with the profiler set up correctly. I
am also throwing Paul Rubin's RegEx entry in to the race as well. I've got
a web page going together now with all the mind numbing details. The short
story is that Duncan's suggestion of maketrans/translate looks like it will
pull ahead when the number of substitutions increase beyond some number N.
Right now, I don't know what N is going to be.
In terms of the OP's original request for replacing 2 chars, Duncan's and
stringReplace are dead even. With my vote going for stringReplace. +0
I'll post the url when it's complete along with my test harness and the code
for everyone to pick apart. If I've made mistakes I would appreciate
anyones assistance in pointing them out. Personally, I'm using this as a
chance to beef up my profiling knowledge.
more to follow,
Jeff Hinrichs
More information about the Python-list
mailing list