This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yselivanov
Recipients mark.dickinson, pitrou, serhiy.storchaka, vstinner, yselivanov
Date 2016-02-10.15:32:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1455118347.3.0.638544963494.issue26289@psf.upfronthosting.co.za>
In-reply-to
Content
Attaching an updated patch.

> 1. I think you're missing the final multiplication by Py_SIZE(b) in the fast_mod code. Which is odd, because your tests should catch that. So either you didn't run the tests, or that code path isn't being used somehow.

Thanks.  Not sure how this happened :(

> 2. Talking of tests, it would be good to have tests (for both // and %) for the case where the dividend is an exact multiple of the divisor.

Done.

> 3. Negative divisors almost never come up in real life, so you might also consider restricting the optimisations to the case Py_SIZE(b) == 1 (rather than ABS(Py_SIZE(b)) == 1). If that makes any speed difference at all for the case of positive divisors, then it's probably worth it. If not, then don't worry about it.

Tried it, the difference is very small.  For modulo division it's ~0.225 usec vs ~0.23 usec for [-m timeit -s "x=22331" "x%2;x%3;x%4;x%5;x%6;x%7;x%8;x%99;x%100;"]
History
Date User Action Args
2016-02-10 15:32:27yselivanovsetrecipients: + yselivanov, mark.dickinson, pitrou, vstinner, serhiy.storchaka
2016-02-10 15:32:27yselivanovsetmessageid: <1455118347.3.0.638544963494.issue26289@psf.upfronthosting.co.za>
2016-02-10 15:32:27yselivanovlinkissue26289 messages
2016-02-10 15:32:27yselivanovcreate