[Python-Dev] Scope object (Re: nonlocals() function?)

Cesare Di Mauro cesare.di.mauro at gmail.com
Thu Apr 8 15:54:21 CEST 2010


2010/4/7 Steven D'Aprano <steve at pearwood.info>

> On Tue, 6 Apr 2010 04:25:08 pm Cesare Di Mauro wrote:
>
> > It will certainly. There's MUCH that can be optimized to let CPython
> > squeeze more performance from static analysis (even a gross one) on
> > locals.
> [...]
> > They are just "dummy" examples, but can make it clear how far
> > optimizations can go with static analysis on locals. Python is a
> > language that make it possible to use such analysis at compile time,
> > and I think it is a very good thing.
>
> I'm not opposed to the idea of optimisations in general (far from it!)
> but in case anyone is thinking about doing any work in this area,
> please be careful about floating point optimisations. E.g. given a float
> x, you can't assume that x*0 == 0. Nor can you assume that 0-x is the
> same as -x. (The second is *almost* always correct, except for one
> float value.)
>
> See, for example, the various writings by Professor Kahan:
>
> http://www.drdobbs.com/184410314
> http://www.cs.berkeley.edu/~wkahan/
>
> Most of the issues discussed apply to languages that deal with floats at
> a lower level than Python does, but still, simple minded optimizations
> will break corner cases no matter what language you use.
>
> --
> Steven D'Aprano


Thanks for the useful links.

I never applied such kind of optimizations, and I think I'll never to do it
anyway. :)

Cesare
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20100408/3bd54bc1/attachment.html>


More information about the Python-Dev mailing list