[PATCH 2 of 3] dirstate: test normalize is not None instead of using a no-op lambda

Matt Mackall mpm at selenic.com
Tue Dec 4 01:29:45 CST 2012


On Mon, 2012-12-03 at 16:32 -0800, Siddharth Agarwal wrote:
> On 12/03/2012 02:33 PM, Matt Mackall wrote:
> > $ python -m timeit -s 'n = None' -c 'if n: pass'
> > 100000000 loops, best of 3: 0.0143 usec per loop
> > $ python -m timeit -s 'n = None' -c 'if n is not None: pass'
> > 100000000 loops, best of 3: 0.0178 usec per loop
> 
> Switching to "if normalize:" didn't bring about a measurable difference 
> to perfstatus -u. The lambda variant is relatively a lot slower, so 
> there's no surprise that I saw a perf difference there. On my install:
> 
> $ python -m timeit -s 'n = lambda x, y, z: x' -c 'n(True, True, True)'
> 1000000 loops, best of 3: 0.22 usec per loop
> $ python -m timeit -s 'n = lambda x, y, z: x' -c 'n(None, None, None)'
> 10000000 loops, best of 3: 0.142 usec per loop
> $ python -m timeit -s 'n = None' -c 'if n is not None: pass'
> 10000000 loops, best of 3: 0.044 usec per loop
> $ python -m timeit -s 'n = None' -c 'if n: pass'
> 10000000 loops, best of 3: 0.036 usec per loop
> 
> However, if you think it's better clarity-wise, I can resend the patch 
> with the change.

Please.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list