On 2016-06-02 21:12, Robert Bradshaw wrote:
"if isinstance(x, (int,long))", which is parsed as "if PyInt_Check(x) or
PyLong_Check(x)" is slightly slower than "if PyInt_Check(x) ||
PyLong_Check(x)".

That is very surprising. How much slower?

With GCC 4.9.3, roughly 4% for a simple loop like

for x in L:
    if isinstance(x, (int, long)):
        return True

I wonder if
this is due to gcc's expectations about the likelyhood of truth values
of the subexpressions in a logical or vs. an if...

I doubt it. It's just the optimizer which optimizes arithmetic better than if/goto.
_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel

Reply via email to