Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79939
| From | Stefan Behnel <stefan_ml@behnel.de> |
|---|---|
| Subject | Re: (-1)**1000 |
| Date | 2014-10-29 20:31 +0100 |
| References | <54476a77$0$21664$426a74cc@news.free.fr> <544d5499$0$41762$c3e8da3$5d8fb80f@news.astraweb.com> <m2jmgm$a2f$1@ger.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15309.1414611090.18130.python-list@python.org> (permalink) |
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
(-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