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.

Thanks,
Donnie

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to