(original) (raw)
2010/4/7 Steven D'Aprano <steve@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 farI'm not opposed to the idea of optimisations in general (far from it!)
> 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.
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