Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #2576

Re: integer multiplication

From Terry Reedy <tjreedy@udel.edu>
Subject Re: integer multiplication
Date 2011-04-04 12:41 -0400
References <BANLkTik5Oq0AE5-yrbSa2oES5_g8+gspeA@mail.gmail.com> <mailman.177.1301880825.2990.python-list@python.org> <7xy63qpnrh.fsf@ruckus.brouhaha.com>
Newsgroups comp.lang.python
Message-ID <mailman.9.1301935309.9059.python-list@python.org> (permalink)

Show all headers | View raw


On 4/4/2011 1:51 AM, Paul Rubin wrote:

> I didn't realize Python used Karatsuba.  The main issue is probably that
> Python uses a straightforward portable C implementation that's not
> terribly efficient,

but relatively easy for a couple of people to maintain. For (C)Python 3, 
which no longer has a C int type, I believe changes were focused on 
making calculations with small integers almost as fast as in 2.x.

(I believe that retaining two implementations internally was considered 
but rejected. Could be wrong.)

 >If you look for the gmpy module, it gives you a way to use gmp from
 >Python.  In crypto code (lots of 1024 bit modular exponentials) I think
 >I found gmpy to be around 4x faster than Python longs.

For specialized use, specialized gmpy is the way to go.

I am curious how gmpy compares to 3.x ints (longs) with small number 
calculations like 3+5 or 3*5.


-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: integer multiplication geremy condra <debatem1@gmail.com> - 2011-04-03 18:33 -0700
  Re: integer multiplication Paul Rubin <no.email@nospam.invalid> - 2011-04-03 22:51 -0700
    Re: integer multiplication Terry Reedy <tjreedy@udel.edu> - 2011-04-04 12:41 -0400
      Re: integer multiplication casevh <casevh@gmail.com> - 2011-04-04 12:18 -0700
    Re: integer multiplication geremy condra <debatem1@gmail.com> - 2011-04-04 10:20 -0700
    Re: integer multiplication Terry Reedy <tjreedy@udel.edu> - 2011-04-04 15:04 -0400

csiph-web