[merge] [#146176] fix Dirstate.set_state_from_inventory
Andrew Bennetts
andrew at canonical.com
Tue Oct 9 04:16:15 BST 2007
Robert Collins wrote:
[...]
>
> Just a note here -
> 'not current_new' is measurably faster than 'current_new is None'. Is
> there some reason to change these two conditions?
Wow, so it is. timeit says 0.142 µsec versus 0.17 µsec on my laptop.
A quick peek at Python/ceval.c shows that the UNARY_NOT opcode just invokes
PyObject_IsTrue, which very quickly checks if the object == Py_None. But
COMPARE_OP is much further down in the big ceval case statement, and is a bit
more complicated than UNARY_NOT. In particular I was surprised that the
PyCmp_IS/PyCmp_IS_NOT cases aren't inlined in the eval loop (unless both
operands are ints).
</interpreter-trivia>
-Andrew.
More information about the bazaar
mailing list