Author pitrou
Recipients gvanrossum, pitrou
Date 2013-02-09.16:07:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1360426050.88.0.977206147009.issue17170@psf.upfronthosting.co.za>
In-reply-to
Content
> Characteristics of the data: the names are relatively short (1-10
> characters usually)

$ ./python -m timeit -s "a = 'hundred'" "'x' in a"
10000000 loops, best of 3: 0.0431 usec per loop
$ ./python -m timeit -s "a = 'hundred'" "a.find('x')"
1000000 loops, best of 3: 0.206 usec per loop
$ ./python -m timeit -s "a = 'hundred'" "a.replace('x', 'y')"
10000000 loops, best of 3: 0.198 usec per loop

Basically, it's simply the overhead of method calls over operator calls. You only see it because the strings are very short, and therefore the cost of finding / replacing is tiny.
History
Date User Action Args
2013-02-09 16:07:30pitrousetrecipients: + pitrou, gvanrossum
2013-02-09 16:07:30pitrousetmessageid: <1360426050.88.0.977206147009.issue17170@psf.upfronthosting.co.za>
2013-02-09 16:07:30pitroulinkissue17170 messages
2013-02-09 16:07:30pitroucreate