subexpressions

Paul Boddie paul at boddie.org.uk
Fri Jun 1 08:04:03 EDT 2007


On 1 Jun, 12:55, Steve Howell <showel... at yahoo.com> wrote:
>
> FWIW there's the possibility that even without a
> subexpression syntax, some Python implementations
> would detect the duplication of x*x and optimize that
> for you.  It would have to know that x*x had no side
> effects, which I think is a safe assumption even in a
> dynamic language like Python.

On the basis of you believing that x is one of the built-in numeric
types, yes, but how does the compiler know that?

Paul




More information about the Python-list mailing list