<div class="gmail_quote">On Tue, Jan 4, 2011 at 9:33 AM, Lukas Lueg <span dir="ltr">&lt;<a href="mailto:lukas.lueg@googlemail.com">lukas.lueg@googlemail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
The keys are immutable anyway so the instances of PyDict could manage<br>
a opaque value (in fact, a counter) that changes every time a new<br>
value is written to any key. Once we get a reference out of the dict,<br>
we can can do very fast lookups by passing the key, the reference we<br>
know from the last lookup and our last state. The lookup returns a new<br>
reference and the new state.<br>
If the dict has not changed, the state doesnt change and the reference<br>
is simply taken from the passed value passed to the lookup. That way<br>
the code remains the same no matter if the dict has changed or not.<br></blockquote><div><br></div><div>I have had similar ideas in the past but have never found time to explore them.  The same mechanism could also be used to speed up attribute access on objects.</div>
</div><br>-- <br>Daniel Stutzbach<br>