[MERGE][bug #297831] don't call chdir('')
Marius Kruger
amanic at gmail.com
Wed Nov 19 21:05:55 GMT 2008
2008/11/19 John Arbash Meinel <john at arbash-meinel.com>
> $ TIMEIT -s 'x = ""' 'if x != "": pass'
> 10000000 loops, best of 3: 0.0675 usec per loop
> and
> $ TIMEIT -s 'x = "this/is/a/longer/path"' 'if x != "": pass'
> 10000000 loops, best of 3: 0.0631 usec per loop
>
> versus
>
> $ TIMEIT -s 'x = ""' 'if x: pass'
> 10000000 loops, best of 3: 0.0465 usec per loop
> and
> $ TIMEIT -s 'x = "this/is/a/longer/path"' 'if x: pass'
> 10000000 loops, best of 3: 0.0421 usec per loop
>
>
> Note that this is dramatically different than using bool()
> $ TIMEIT -s 'x = ""' 'if bool(x): pass'
> 1000000 loops, best of 3: 0.266 usec per loop
> $ TIMEIT -s 'x = "this/is/a/longer/path"' 'if bool(x): pass'
> 1000000 loops, best of 3: 0.264 usec per loop
...
I'm interested to know how it compares with your initial alternative:
$ TIMEIT -s 'x = ""' 'if len(x) == 0: pass'
regards
marius
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/bazaar/attachments/20081119/807ab7a2/attachment.htm
More information about the bazaar
mailing list