<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 27 October 2014 01:14, Jon Ribbens <span dir="ltr"><<a href="mailto:jon+usenet@unequivocal.co.uk" target="_blank">jon+usenet@unequivocal.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have a need, in a Python C extension I am writing, for lists and<br>
dictionaries with "lazy evaluation" - by which I mean that at least<br>
some of the values in the lists/dictionaries are "proxy objects"<br>
which, rather than returning as themselves, should return the thing<br>
they are a proxy for when retrieved. This is because retrieving<br>
the proxied objects is expensive and only a small minority of them<br>
will actually be accessed, so retrieving them all before they are<br>
actually accessed is massively inefficient.<br></blockquote><div><br></div><div>Why not put proxy objects into the list/dict? Have a look at the weakref module for an API that may be suitable for such proxy objects (if you used the same API, that would also allow you to transparently use weakrefs in your lists/dicts).</div><div><br></div><div>Tim Delaney </div></div></div></div>