Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!gegeweb.org!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'int': 0.05; 'terry': 0.07; 'type,': 0.07; 'python': 0.07; '3.x': 0.09; 'compares': 0.09; 'integers': 0.09; 'internally': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'rejected.': 0.09; 'am,': 0.14; 'wrote:': 0.14; '1024': 0.16; 'reedy': 0.16; 'jan': 0.22; 'code': 0.22; 'header:In-Reply-To:1': 0.22; 'curious': 0.23; 'module,': 0.23; 'retaining': 0.23; "didn't": 0.25; 'changes': 0.29; 'probably': 0.30; 'paul': 0.32; 'to:addr:python-list': 0.32; 'go.': 0.33; 'relatively': 0.33; 'bit': 0.33; 'uses': 0.34; 'header:X-Complaints-To:1': 0.34; 'couple': 0.35; 'header:User- Agent:1': 0.35; 'think': 0.36; 'considered': 0.36; 'two': 0.37; 'issue': 0.37; 'faster': 0.38; 'but': 0.38; 'used': 0.38; 'received:org': 0.38; 'focused': 0.39; 'realize': 0.39; 'to:addr:python.org': 0.39; 'could': 0.39; 'header:Mime- Version:1': 0.39; 'how': 0.39; 'header:Received:5': 0.40; 'specialized': 0.60; 'making': 0.62; 'believe': 0.66; 'terribly': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: integer multiplication Date: Mon, 04 Apr 2011 12:41:31 -0400 References: <7xy63qpnrh.fsf@ruckus.brouhaha.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 In-Reply-To: <7xy63qpnrh.fsf@ruckus.brouhaha.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1301935310 news.xs4all.nl 34849 [::ffff:82.94.164.166]:50031 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:2576 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