On 4/11/2015 5:10 PM, Chris Angelico wrote:
On Sun, Apr 12, 2015 at 3:52 AM, Paul Rubin <no.email@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
--
https://mail.python.org/mailman/listinfo/python-list