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


Groups > comp.lang.python > #79939

Re: (-1)**1000

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.87.MISMATCH!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'interpreter': 0.05; 'may,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'works.': 0.09; 'python': 0.11; 'assume': 0.14; 'ast': 0.16; 'benefit.': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'ought': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'unlikely': 0.16; 'language': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'wed,': 0.18; 'stefan': 0.19; '>>>': 0.22; 'rules': 0.22; 'header :User-Agent:1': 0.23; 'case.': 0.24; 'math': 0.24; 'compare': 0.26; 'defined': 0.27; 'header:X-Complaints-To:1': 0.27; 'header :In-Reply-To:1': 0.27; '(which': 0.31; 'program,': 0.31; 'code': 0.31; 'clever': 0.31; 'know.': 0.32; 'cases': 0.33; 'guess': 0.33; 'something': 0.35; 'received:84': 0.35; 'there': 0.35; '+0200,': 0.36; 'possible': 0.36; 'example,': 0.37; 'expected': 0.38; 'generic': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'little': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'impact': 0.61; 'simply': 0.61; 'real': 0.63; 'such': 0.63; 'provide': 0.64; 'benefit': 0.68; 'batchelder': 0.84; 'optimisation': 0.84; 'taken.': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: (-1)**1000
Date Wed, 29 Oct 2014 20:31:11 +0100
References <54476a77$0$21664$426a74cc@news.free.fr> <544d5499$0$41762$c3e8da3$5d8fb80f@news.astraweb.com> <m2jmgm$a2f$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host dslb-084-056-044-091.084.056.pools.vodafone-ip.de
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
In-Reply-To <m2jmgm$a2f$1@ger.gmane.org>
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.15309.1414611090.18130.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1414611091 news.xs4all.nl 2885 [2001:888:2000:d::a6]:51574
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:79939

Show key headers only | View raw


Ned Batchelder schrieb am 26.10.2014 um 21:45:
> On 10/26/14 4:07 PM, Tony the Tiger wrote:
>> On Wed, 22 Oct 2014 10:27:34 +0200, ast wrote:
>>
>>> If i am writing (-1)**1000 on a python program, will the interpreter do
>>> (-1)*(-1)*...*(-1) or something clever ?
>>
>> Even vs. odd. It ought to know. I would assume from a set of defined
>> rules how math works.
> 
> There is such a thing as an optimization that isn't worthwhile to perform,
> simply because it's expected to provide so little benefit.  The language
> implementors have to trade off the cost of adding the optimization to the
> implementation, against the possible benefit people would get from it.
> 
> Benefit in this case would have to include a guess as to how often real
> programs would hit the optimization case.

... and also compare it to the number of cases where the optimisation
(which may, for example, need to check for an optimisable value or set of
values) slows down the generic (unoptimised) code path that is actually taken.

Even if the code impact on the implementation is small enough to be
acceptable, an optimisation for unlikely cases may provide a net-loss for
the "normal" code. So there are several reasons why an "obvious"
optimisation may be a bad idea.

Stefan

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


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 albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-11-04 00:46 +0000
    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