Ned Batchelder ned at nedbatchelder.com
Sun Oct 26 21:45:12 CET 2014

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.

Ned Batchelder, http://nedbatchelder.com

More information about the Python-list mailing list