[Python-checkins] cpython: Since the index is always non-negative, use faster unsigned division and modulo.
Terry Reedy
tjreedy at udel.edu
Fri Feb 27 22:17:09 CET 2015
On 2/27/2015 3:43 PM, raymond.hettinger wrote:
> https://hg.python.org/cpython/rev/91a1613e161c
> changeset: 94780:91a1613e161c
> user: Raymond Hettinger <python at rcn.com>
> date: Fri Feb 27 12:42:54 2015 -0800
> summary:
> Since the index is always non-negative, use faster unsigned division and modulo.
> - n = i / BLOCKLEN;
> + assert(i >= 0);
> + n = (Py_ssize_t)((unsigned) i / BLOCKLEN);
> + i = (Py_ssize_t)((unsigned) i % BLOCKLEN);
> i %= BLOCKLEN;
Should this last line be removed after being replaced by the line above?
I believe it is now a time-wasting no-op after the addition.
Terry
More information about the Python-checkins
mailing list