New submission from Stefan Behnel: The attached patch adds fast paths for PyLong division by 1 and -1, as well as dividing 0 by something. This was found helpful for fractions normalisation, as the GCD that is divided by can often be |1|, but firing up the whole division machinery for this eats a lot of CPU cycles for nothing.
There are currently two test failures in test_long.py because dividing a huge number by 1 or -1 no longer raises an OverflowError. This is a behavioural change, but I find it acceptable. If others agree, I'll fix the tests and submit a new patch. ---------- components: Interpreter Core files: div_by_1_fast_path.patch keywords: patch messages: 227590 nosy: mark.dickinson, pitrou, scoder, serhiy.storchaka priority: normal severity: normal status: open title: Optimise PyLong division by 1 or -1 type: performance versions: Python 3.5 Added file: http://bugs.python.org/file36729/div_by_1_fast_path.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22501> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com