find all multiplicands and multipliers for a number

Terry Reedy tjreedy at udel.edu
Sun Apr 12 01:58:50 CEST 2015


On 4/11/2015 5:10 PM, Chris Angelico wrote:
> On Sun, Apr 12, 2015 at 3:52 AM, Paul Rubin <no.email at nospam.invalid> wrote:
>>> PS Note that you're being "wasteful" by multiplying c*c over and over
>>
>> Yeah this is a reasonable point, though most of the c's should fit in a
>> machine word, at least in my 64-bit system.  I think Python still
>> separates ints and longs in the implementation.
>
> I don't think it does.

In 3.0, the 2.x int class and intobject.c were removed and the long 
class was renamed int, while longobject.c remained, with code relevant 
to the int class removed. 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.

-- 
Terry Jan Reedy




More information about the Python-list mailing list