1 |
On Wed, Mar 15, 2006 at 11:14:04PM -0800, Donnie Berkholz wrote: |
2 |
> Brian Harring wrote: |
3 |
> > python -m timeit -s 's="asdf"*400;s+="fdsa.ebuild"' 's.endswith(".ebuild")' |
4 |
> > 1000000 loops, best of 3: 0.88 usec per loop |
5 |
> |
6 |
> > python -m timeit -s 's="asdf"*400;s+="fdsa.ebuild"' 's[-7:] == ".ebuild"' |
7 |
> > 1000000 loops, best of 3: 0.564 usec per loop |
8 |
> |
9 |
> > Use endswith |
10 |
> |
11 |
> > oddly, worth noting that startswith differs in this behaviour... |
12 |
> > python -m timeit -s 's="asdf"*400;s+="fdsa.ebuild"' 's[:7] == ".ebuild"' |
13 |
> > 1000000 loops, best of 3: 0.592 usec per loop |
14 |
> |
15 |
> > python -m timeit -s 's="asdf"*400;s+="fdsa.ebuild"' 's.startswith(".ebuild")' |
16 |
> > 1000000 loops, best of 3: 0.842 usec per loop |
17 |
> |
18 |
> Um, those both read the same way to me. You just switched the ordering |
19 |
> around, so the (starts|ends)with is on the bottom instead of the top, |
20 |
> but both times (starts|ends)with is longer. |
21 |
|
22 |
This is why crack is bad, mm'kay. |
23 |
|
24 |
/me lights the pipe and goes back to his corner. |
25 |
|
26 |
Pardon, just did a quick test and screwed the results ;) |
27 |
~harring |