Fastest way to calculate leading whitespace

Wolfram Hinderer wolfram.hinderer at googlemail.com
Sun May 9 08:58:18 EDT 2010


On 8 Mai, 21:46, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> On Sat, 08 May 2010 12:15:22 -0700, Wolfram Hinderer wrote:
> > Returning s[:-1 - len(t)] is faster.
>
> I'm sure it is. Unfortunately, it's also incorrect.

> However, s[:-len(t)] should be both faster and correct.

Ouch. Thanks for correcting me.

No, I'll never tell how that -1 crept in...



More information about the Python-list mailing list