Question about math.pi is mutable

Ben Finney ben+python at benfinney.id.au
Mon Nov 9 14:45:40 EST 2015


Steven D'Aprano <steve at pearwood.info> writes:

> The compiler doesn't need to decide in advance whether or not the
> module attributes have been changed. It can decide that at runtime,
> just before actually looking up the attribute. In pseudo-code:
>
>     if attribute might have changed:
>         use the slow path just like today
>     else:
>         use the optimized fast path

As you have pointed out earlier, the “attribute might have changed”
condition is set by *any* non-trivial code — notably, a function
call, though that doesn't exhaust the ways of setting that condition.

So the remaining space of code that is safe for the proposed
optimisation is trivially small. Why bother with such optimisations, if
the only code that can benefit is *already* small and simple?

I'm not asking you (Steven) to defend the proposal, I'm pointing out
that the “problem” being addressed is essentially the dynamism of
Python. The proposal is misguided.

-- 
 \         “Truth would quickly cease to become stranger than fiction, |
  `\                     once we got as used to it.” —Henry L. Mencken |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list