[pypy-dev] Integer division

Armin Rigo armin.rigo at gmail.com
Thu Jun 1 06:53:55 EDT 2017


Hi,

On 31 May 2017 at 17:11, Tuom Larsen <tuom.larsen at gmail.com> wrote:
>             # k = i//j # 2.12 seconds
>             k = int(i/j) # 0.98 seconds

Note first that if you don't do anything with 'k', it might be optimized away.

I just wrote a pure C example doing the same thing, and indeed
converting the integers to float, dividing, and then converting back
to integer... is 2.2x times faster there too.

Go figure it out.  I have no idea why the CPU behaves like that.
Maybe Neal can provide a clue.


A bientôt,

Armin.


More information about the pypy-dev mailing list