2010/4/6 Greg Ewing <greg.ew...@canterbury.ac.nz> > 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. >> > > But can the existing locals() function be implemented in > the face of such optimisations? > > If it can, then a "locals view" object shouldn't be too much > harder. > > If it can't, then you have already given up full CPython > compatibility. > > -- > Greg
A read-only locals view can be a good comprise, because at least the first example I showed can be approached well. For the second example, there's no full compatibility with the current CPython implementation. But implementations can change over the time: we can clearly define that on future CPython versions no assumptions must be made about locals "usage", and in general about instructions generation. The most important thing is that the function f() does what is called to do: return the numeric constant 3. This gives us the opportunity to schedule more efficient optimizations, without losing generality about the language (only some weird tricks will not be supported). Cesare
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com