On Wed, Mar 15, 2006 at 11:14:04PM -0800, Donnie Berkholz wrote:
> Brian Harring wrote:
> > python -m timeit -s 's="asdf"*400;s+="fdsa.ebuild"' 's.endswith(".ebuild")'
> > 1000000 loops, best of 3: 0.88 usec per loop
> 
> > python -m timeit -s 's="asdf"*400;s+="fdsa.ebuild"' 's[-7:] == ".ebuild"'
> > 1000000 loops, best of 3: 0.564 usec per loop
> 
> > Use endswith
> 
> > oddly, worth noting that startswith differs in this behaviour...
> > python -m timeit -s 's="asdf"*400;s+="fdsa.ebuild"' 's[:7] == ".ebuild"'
> > 1000000 loops, best of 3: 0.592 usec per loop
> 
> > python -m timeit -s 's="asdf"*400;s+="fdsa.ebuild"' 
> > 's.startswith(".ebuild")'
> > 1000000 loops, best of 3: 0.842 usec per loop
> 
> Um, those both read the same way to me. You just switched the ordering
> around, so the (starts|ends)with is on the bottom instead of the top,
> but both times (starts|ends)with is longer.

This is why crack is bad, mm'kay.

/me lights the pipe and goes back to his corner.

Pardon, just did a quick test and screwed the results ;)
~harring

Attachment: pgpB6yC53TYdU.pgp
Description: PGP signature

Reply via email to