[Python-ideas] Accelerated attr lookups
rasky at develer.com
Thu Jun 28 22:14:37 CEST 2007
On 19/06/2007 17.13, Eyal Lotem wrote:
> Hi, I have attached a patch at:
> A common optimization tip for Python code is to use locals rather than
> globals. This converts dictionary lookups of (interned) strings to
> tuple indexing. I have created a patch that achieves this speed
> benefit "automatically" for all globals and builtins, by adding a
> feature to dictobjects.
> Additionally, the idea of this patch is that it puts down the
> necessary infrastructure to also allow virtually all attribute
> accesses to also be
> accelerated in the same way (with some extra work, of course).
> I have already suggested this before but I got the impression that the
> spirit of the replies was "talk is cheap, show us the
> code/benchmarks". So I wrote some code.
> Getting the changes to work was not easy, and required learning about
> the nuances of dictobject's, their re-entrancy issues, etc. These
> changes do slow down dictobjects, but it seems that this slowdown is
> more than offset by the speed increase of builtins/globals access.
How does it compare with this patch:
More information about the Python-ideas