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


Groups > comp.lang.python > #2542

Re: integer multiplication

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <debatem1@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'algorithms': 0.07; 'python': 0.07; 'list)': 0.09; 'sun,': 0.09; 'to:name:python list': 0.09; 'pm,': 0.11; 'wrote:': 0.14; '(sorry': 0.16; 'breach': 0.16; 'integers.': 0.16; 'outline': 0.16; 'tarball': 0.16; 'question.': 0.18; 'to:2**1': 0.20; 'seems': 0.21; 'header :In-Reply-To:1': 0.22; 'compared': 0.22; 'trying': 0.23; 'integer': 0.23; 'version': 0.25; 'compare': 0.26; 'message- id:@mail.gmail.com': 0.28; 'least': 0.30; 'at.': 0.31; 'use?': 0.31; 'does': 0.31; 'it.': 0.31; "can't": 0.31; 'supposed': 0.31; 'anyone': 0.31; 'to:addr:python-list': 0.32; 'source': 0.32; 'thank': 0.32; 'idea': 0.32; "i've": 0.33; 'implemented': 0.33; 'minor': 0.33; 'file': 0.35; 'correctly': 0.35; 'received:209.85.216.46': 0.35; 'received:mail- qw0-f46.google.com': 0.35; 'considered': 0.36; 'skip:o 20': 0.37; 'received:209.85': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'used': 0.38; 'to:addr:python.org': 0.39; 'where': 0.39; 'received:209': 0.39; 'how': 0.39; 'takes': 0.40; 'would': 0.40; 'header:Received:5': 0.40; 'reply': 0.61; '2011': 0.62; 'here.': 0.68; 'double': 0.69; 'machine,': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=7VE+p834zSqT2BSfnSH9WjGtVr/2w3e6IbBNAOu/Uvo=; b=GCEbn2wox68T339j+op9xeI96gk2jZvx37kZXCjVuWiV0yhw2QEp361RRWEDkrdXO8 qVZgM6SWChZ6BqtwSzE64VAxX4W+63EXID/MiYt5AdnHJrGprn8bmyNLhj+E/hKQ8V9c r7vsFGq4Bh4ldXhdV2UVJFDioxtLN2Ot8194Q=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=ETL2rwhTQuBHntDr5BgJ1ZNvphQUuzFhdz0KlLWmsr+auDvvFbiR4YnmjksldENy4t 7S/aKkpRf26IPPnubr7QXY7HC0dSZepstMfQt5eh98PVcuvBl7SABuRcVmr/jd+dZlIJ US8FOofS/jmHW0BA7MGIoO5SAnbKVxXR/Dgy4=
MIME-Version 1.0
In-Reply-To <BANLkTim6fV0tW9ZB07q6xxtYrwZ5mB__+w@mail.gmail.com>
References <BANLkTik5Oq0AE5-yrbSa2oES5_g8+gspeA@mail.gmail.com> <AANLkTimsXzAxUBcL=Z8CbUcgGVmw-=_Dp=Z-zAb1u24j@mail.gmail.com> <BANLkTim6fV0tW9ZB07q6xxtYrwZ5mB__+w@mail.gmail.com>
Date Sun, 3 Apr 2011 18:46:54 -0700
Subject Re: integer multiplication
From geremy condra <debatem1@gmail.com>
To Eddie Tsay <jianyu44@gmail.com>, Python List <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.178.1301881618.2990.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 82.94.164.166
X-Trace 1301881618 news.xs4all.nl 41102 [::ffff:82.94.164.166]:40601
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:2542

Show key headers only | View raw


On Sun, Apr 3, 2011 at 6:41 PM, Eddie Tsay <jianyu44@gmail.com> wrote:
>
> On Sun, Apr 3, 2011 at 6:33 PM, geremy condra <debatem1@gmail.com> wrote:
>>
>> On Sun, Apr 3, 2011 at 6:20 PM, Eddie Tsay <jianyu44@gmail.com> wrote:
>> > Does anyone know what algorithms for integer multiplication does Python
>> > use?
>> > I am trying to compare it to those used by Sage as it seems like it
>> > takes
>> > much longer for Python to do large integer multiplication as compared to
>> > Sage (anyone know off the top of their heads?)
>> > thank you
>>
>> (sorry for the double email, this was supposed to go to the list)
>>
>> Karatsuba multiplication, at least for large integers.
>>
>> Geremy Condra
>
>
> Thank you for replying to my question.
> Do you have any idea how I would be able to find how they do this
> multiplication in the python source code? I've been poking around the
> documentation and can't find the area where they outline it.
> Thank you for your reply =)
> Eddie

In the Python3 source tarball its in Objects/longobject.c. I only have
the 3.2a1 tarball on this machine, but I found the 'grade school'
method implemented in x_mul on line 2765 of that file and karatsuba
multiplication as k_mul on line 2890. YMMV depending on what version
you're looking at.

Just as a side-note, top-posting is considered a minor breach of
netiquette on python-list. I've rearranged the reply correctly here.

Geremy Condra

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


Thread

Re: integer multiplication geremy condra <debatem1@gmail.com> - 2011-04-03 18:46 -0700

csiph-web