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


Groups > comp.lang.python > #87518

Re: More or less code in python?

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.021
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'python.': 0.02; 'base.': 0.05; 'parser': 0.07; 'subject:code': 0.07; 'string': 0.09; 'arguments': 0.09; 'assuming': 0.09; 'python': 0.11; 'subject:More': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User-Agent:1': 0.23; "aren't": 0.24; 'instead.': 0.24; 'paul': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'especially': 0.30; '3.x': 0.31; 'mod': 0.31; 'operators': 0.31; 'writes:': 0.31; 'common': 0.35; 'beyond': 0.35; 'convert': 0.35; 'add': 0.35; 'really': 0.36; 'earth': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'similar': 0.36; 'two': 0.37; 'implement': 0.38; 'form,': 0.38; 'generic': 0.38; 'massive': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'course.': 0.60; "you're": 0.61; 'back': 0.62; 'email addr:gmail.com': 0.63; 'different': 0.65; 'taking': 0.65; 'charset:windows-1252': 0.65; 'received:74.208': 0.68; '2015': 0.84; 'intending': 0.84; 'mars': 0.84
Date Mon, 16 Mar 2015 03:32:30 -0400
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
MIME-Version 1.0
To python-list@python.org
Subject Re: More or less code in python?
References <8412cc81-fbd2-4590-9db3-12c65ba2ee35@googlegroups.com> <mailman.399.1426444300.21433.python-list@python.org> <53b202e7-327b-412a-a5e0-debca5c3b489@googlegroups.com> <87h9tmt796.fsf@jester.gateway.sonic.net> <dbdd7715-7418-49d1-9c52-e7cfdf16d733@googlegroups.com>
In-Reply-To <dbdd7715-7418-49d1-9c52-e7cfdf16d733@googlegroups.com>
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 8bit
X-Provags-ID V03:K0:Igoxb8artpvNPsNtCKAgiOHt6QViiWL6mofHdokfBemss81ahj/ ER09Mjq0YV4CPkKDWFQ5FTAe+sOj6q8gzJJSSvviBEH62j55PYDUoqjMvkLvXLtaxwVhNlh deSvfda3R/tqtp7ZSWzQKg5kTwkTeqC9ZFG70ZNFQP+wBkwT2CzGuI7tXbulp6OmtXdm3yh ionYCqD1o4bBkqOLp/EiQ==
X-UI-Out-Filterresults notjunk:1;
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.418.1426491168.21433.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1426491168 news.xs4all.nl 2894 [2001:888:2000:d::a6]:59137
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:87518

Show key headers only | View raw


On 03/15/2015 03:09 PM, jonas.thornvall@gmail.com wrote:
> Den söndag 15 mars 2015 kl. 20:01:36 UTC+1 skrev Paul Rubin:
>> jonas.thornvall@gmail.com writes:
>>> I though it would be interesting doing comparissons in timing adding
>>> massive digits in different bases. Especially in Python.
>>
>> Python has built-in bignums.  Try "print 2**500".
>
> I will try implement the common operators + - * / pow sqrt operators mod floor and and a generic parser taking arguments in any base.
>

Why on earth would you bother?  Use the int(x, base) to convert a string 
in an arbitrary base to an int.  Write a similar function to convert an 
int back into a string of the desired base.  Of course, your strings 
aren't in a standard form, so you'd have to do some work to get those 
instead.  Are you really intending to use a base beyond 36?

Then to add two numbers, use +     To multiply, use *, and so on.

Assuming Python 3.x of course.  if you're in Python 2, you'd use "long" 
rather than int.

-- 
DaveA

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


Thread

More or less code in python? jonas.thornvall@gmail.com - 2015-03-15 11:07 -0700
  Re: More or less code in python? Joel Goldstick <joel.goldstick@gmail.com> - 2015-03-15 14:31 -0400
    Re: More or less code in python? jonas.thornvall@gmail.com - 2015-03-15 11:56 -0700
    Re: More or less code in python? jonas.thornvall@gmail.com - 2015-03-15 12:00 -0700
      Re: More or less code in python? Paul Rubin <no.email@nospam.invalid> - 2015-03-15 12:01 -0700
        Re: More or less code in python? jonas.thornvall@gmail.com - 2015-03-15 12:03 -0700
        Re: More or less code in python? jonas.thornvall@gmail.com - 2015-03-15 12:09 -0700
          Re: More or less code in python? Dave Angel <davea@davea.name> - 2015-03-16 03:32 -0400
          Re: More or less code in python? Chris Angelico <rosuav@gmail.com> - 2015-03-16 18:36 +1100
          Re: More or less code in python? Dave Angel <davea@davea.name> - 2015-03-16 03:44 -0400
  Re: More or less code in python? Peter Otten <__peter__@web.de> - 2015-03-15 20:15 +0100

csiph-web