Mark Dickinson added the comment:

Victor, can you demonstrate any cases of real code where this optimization 
makes a significant difference?

There are many, many tiny optimisations we *could* be making in 
Objects/longobject.c; each of those potential optimisations adds to the cost of 
maintaining the code, detracts from readability, and potentially even slows 
down the common cases fractionally.  In general, I think we should only be 
applying this sort of optimization when there's a clear benefit to real-world 
code.  I don't think this one crosses that line.

In the (I suspect rare) cases where a piece of real-world code is slowed down 
significantly due to a non-optimized 2**n, the code author still has the option 
of replacing that piece of code with 1<<n manually.  And in some cases, that's 
probably the wrong optimization anyway: an expression like `x * 2**n` would be 
better hand-optimized to `x << n`.

IOW, I'm -1 on making this change.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21420>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to