find all multiplicands and multipliers for a number
rosuav at gmail.com
Sun Apr 12 02:16:31 CEST 2015
On Sun, Apr 12, 2015 at 9:58 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> I believe longobject effectively represents ints in base 2**15 or 2**30 (or
> 31?) for 32 and 64 bit machines, so that products of 'digits' fit in a
> single machine word. (I am not sure if the increased size for 64 bit
> machines was implemented or not.)
>> Performance doesn't seem to change in Py3 as
>> the numbers get bigger:
> I suspect the effect is more dramatic with multiplication.
Sorry, sloppy language. Of course larger numbers will be a bit slower,
but there's no stark change at the edge of the machine word. The
performance loss from going from one limb to two will be comparable to
the loss from going from five to six, where it's already well past
machine integer. In Py2, there's a significant difference between
"int" performance and "long" performance (regardless of the actual
size of integer involved), but Py3 is more consistent.
It's a missed optimization at worst, but the upshot is that a Python
programmer doesn't need to think about integer sizes at all.
More information about the Python-list