On Wed, Aug 19, 2015 at 10:16 PM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> So maybe it's a micro-optimization?


Note, however, that the original post compared "mydict == {}" with "not
mydict". In that case, it's decidedly not an optimization:

firefly% python2.7 -m timeit -s "mydict = {1:2}" "if mydict == {}: pass"
10000000 loops, best of 3: 0.0508 usec per loop
firefly% python2.7 -m timeit -s "mydict = {1:2}" "if not mydict: pass"
10000000 loops, best of 3: 0.0246 usec per loop

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to