New submission from Skip Montanaro <s...@pobox.com>: The why_code enum in ceval.c has values which form a bit set. Comparison of the why variable against multiple values is going to be faster using bitwise operations instead of logical ones. For example, instead of
why == WHY_RETURN || why == WHY_CONTINUE the equivalent bitwise expression is why & (WHY_RETURN | WHY_CONTINUE) which has fewer operations (one vs three treating the rhs of & as a constant). This is already done in one place. The attached patch converts all other expressions of the first form. Also, there are some further manipulations of why in the loop after the fast_block_end. The loop can only be entered if why != WHY_NOT. In the loop when it is set to WHY_NOT, the loop breaks. There is thus no reason to test its value in the while expression. Further, instead of just breaking from the loop and then checking the why != WHY_NOT again, just jump past that check by adding a why_not_here label. The attached patch implements these changes (against the py3k branch). All tests pass on my Mac except test_cmd_line (which has been failing for awhile). Skip ---------- files: unnamed messages: 79470 nosy: skip.montanaro severity: normal status: open title: Faster why variable manipulation in ceval.c Added file: http://bugs.python.org/file12667/unnamed _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4896> _______________________________________
unnamed
Description: Binary data
_______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com