Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79418
| Path | csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone02.am1.xlned.com!bcyclone02.am1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'interpreter': 0.05; '(of': 0.07; 'assignment': 0.07; '22,': 0.09; 'quarter': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'windows': 0.15; 'ast': 0.16; 'enough.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterated': 0.16; 'iteration': 0.16; 'laptop.': 0.16; 'met.': 0.16; 'pause': 0.16; 'language': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'replacing': 0.19; '>>>': 0.22; 'programming': 0.22; 'cc:addr:python.org': 0.22; 'integer': 0.24; 'visible': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'program,': 0.31; 'clever': 0.31; 'purely': 0.31; 'linux': 0.33; 'implemented': 0.33; 'trouble': 0.34; "i'd": 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'half': 0.37; 'performance': 0.37; 'architecture': 0.38; 'handle': 0.38; 'fact': 0.38; 'pm,': 0.38; 'rather': 0.38; 'even': 0.60; 'kind': 0.63; 'skip:n 10': 0.64; 'more': 0.64; 'burden': 0.68; 'million': 0.74; 'potentially': 0.81; 'actually,': 0.84; 'cpu,': 0.84; 'crime.': 0.84; 'seldom': 0.84; 'absolutely': 0.87; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=2BpoM5h4sNeoHPRChYb2CIvq27DII9vPorwRwJKn1nk=; b=vrppLze30d/cDUvLjlh+6QGcmEuJNMdCI/aDPUbE00JGKyc/E6t0XaazUzbdzlEX+h zZo4CZtDKrbkKjQJ1/HbZwHjd6pJSiTmmI0JVRwuHvck6bdssDajTQuCGnJosuV27n3y b1qRS5q3WktZRpI0nv7NGN95H7iXS0/40/pvZzj5FlurYzGVLUjGxtgDixHip14AVGIa uHdNAEVsPlUBUeO0dZGEL4GRWvgdxzt81P7E83e21rOvpcdqDHiU8Vf9TRP0Eg47Y+9x oAK6v4iR61TQCzKeHb21EuLXm4ZR3TsiJnz0TywyY2h3a6ZShl5M852lQUKRacyttAEm +vJw== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.60.97 with SMTP id g1mr33259529igr.2.1413968056417; Wed, 22 Oct 2014 01:54:16 -0700 (PDT) |
| In-Reply-To | <54476a77$0$21664$426a74cc@news.free.fr> |
| References | <54476a77$0$21664$426a74cc@news.free.fr> |
| Date | Wed, 22 Oct 2014 19:54:16 +1100 |
| Subject | Re: (-1)**1000 |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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.15058.1413968065.18130.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1413968065 news.xs4all.nl 2898 [2001:888:2000:d::a6]:44806 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Body-CRC | 1300051520 |
| X-Received-Bytes | 4626 |
| Xref | csiph.com comp.lang.python:79418 |
Show key headers only | View raw
On Wed, Oct 22, 2014 at 7:27 PM, ast <nomail@invalid.com> wrote: > If i am writing (-1)**1000 on a python program, will the > interpreter do (-1)*(-1)*...*(-1) or something clever ? > > In fact i have (-1)**N with N an integer potentially big. Exponentiation is far more efficient than the naive implementation of iterated multiplication. Any modern programming language on any modern CPU architecture should be able to handle this kind of thing. But even the naive approach is likely to be fast enough. >>> x=1 >>> for i in range(1000000): x*=-1 I had to go as far as a million iterations before this, implemented purely in Python with absolutely no optimization, demonstrated a visible pause (of about a quarter second) on my not-exactly-new Windows laptop. My Linux desktop, with a rather hotter CPU, has no trouble with a million, so I'd have to go higher to get a pause out of it. And actually, about half of that time is spent in the loop - replacing the assignment with "pass" still leaves half the iteration time. Poor performance is a crime. Python is innocent until proven guilty. And the burden of proof is seldom met. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
(-1)**1000 "ast" <nomail@invalid.com> - 2014-10-22 10:27 +0200
Re: (-1)**1000 Chris Angelico <rosuav@gmail.com> - 2014-10-22 19:54 +1100
Re: (-1)**1000 "ast" <nomail@invalid.com> - 2014-10-22 11:27 +0200
Re: (-1)**1000 Peter Otten <__peter__@web.de> - 2014-10-22 12:29 +0200
Re: (-1)**1000 Michiel Overtoom <motoom@xs4all.nl> - 2014-10-22 12:38 +0200
Re: (-1)**1000 Tim Chase <python.list@tim.thechases.com> - 2014-10-22 05:43 -0500
Re: (-1)**1000 Peter Otten <__peter__@web.de> - 2014-10-22 13:02 +0200
Re: (-1)**1000 Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-22 08:23 -0600
Re: (-1)**1000 Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-22 08:29 -0600
Re: (-1)**1000 Ned Batchelder <ned@nedbatchelder.com> - 2014-10-22 11:01 -0400
Re: (-1)**1000 wxjmfauth@gmail.com - 2014-10-22 04:35 -0700
Re: (-1)**1000 Peter Otten <__peter__@web.de> - 2014-10-22 11:13 +0200
Re: (-1)**1000 Terry Reedy <tjreedy@udel.edu> - 2014-10-22 13:15 -0400
Re: (-1)**1000 Dave Angel <davea@davea.name> - 2014-10-24 13:57 -0400
Re: (-1)**1000 Tony the Tiger <tony@tiger.invalid> - 2014-10-26 20:07 +0000
Re: (-1)**1000 Ned Batchelder <ned@nedbatchelder.com> - 2014-10-26 16:45 -0400
Re: (-1)**1000 Stefan Behnel <stefan_ml@behnel.de> - 2014-10-29 20:31 +0100
csiph-web