On Mon, Jun 30, 2008 at 12:53 AM, wesley chun <[EMAIL PROTECTED]> wrote: >> As I understand it there are no cases where obj==None and obj is None >> will give different results (which is not true for == vs is in >> general), so is there any practical difference? Maybe you save a >> handful of cycles? > > > as far as i know, that's it. but if this comparison happens a *lot* in > your code, it starts to add up.
I tend to use "is None" because I think it is more readable and explicit, but I would say using it for performance is premature optimization. kent $ python -m timeit -s "a=3" "a==None" 10000000 loops, best of 3: 0.117 usec per loop kent $ python -m timeit -s "a=3" "a is None" 10000000 loops, best of 3: 0.0608 usec per loop You would have to be doing quite a few comparisons for .06 usec to make a difference. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor