Python and the need for speed

Gregory Ewing greg.ewing at
Wed Apr 12 19:09:17 EDT 2017

bart4858 at wrote:

> But the language can also play a part in not allowing certain things to be
> expressed naturally. So the for-loop in the example has to have a
> control-variable even if it's not referenced.

If the compiler can recognise when code is "stupid", it's
probably capable of doing something more intelligent than
just rejecting it outright.

E.g. it could notice that a loop variable wasn't used
anywhere in the function and optimise it out. And it could
recognise x += 1 and emit an ADD_ONE bytecode for it.


More information about the Python-list mailing list