Yury Selivanov added the comment:

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;"]

----------
Added file: http://bugs.python.org/file41886/fast_divmod_5.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26289>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to