[Merge][#111665] bzr rm should remove clean subtrees
Andrew Bennetts
andrew at canonical.com
Mon Aug 13 10:17:16 BST 2007
Alexander Belchenko wrote:
[...]
> > files = [f for f in new_files]
>
> ^-- does list comprehension is faster than slicing operation?
> My simple test shows that is not:
>
> E:\Bazaar\mydev\selftest.miss.dep>python -m timeit "a = range(1000); b = [i for i in a]"
> 1000 loops, best of 3: 381 usec per loop
>
> E:\Bazaar\mydev\selftest.miss.dep>python -m timeit "a = range(1000); b = a[:]"
> 10000 loops, best of 3: 86.7 usec per loop
A better test is:
python -m timeit -s "a = range(1000)" "b = [i for i in a]"
python -m timeit -s "a = range(1000)" "b = a[:]"
> If my test is reliable then I suggest to change the line above to
>
> files = new_files[:]
More readable (and faster) is:
files = list(new_files)
-Andrew.
More information about the bazaar
mailing list