Lazy-evaluation lists/dictionaries

Tim Delaney timothy.c.delaney at
Sun Oct 26 21:36:09 CET 2014

On 27 October 2014 01:14, Jon Ribbens <jon+usenet at> wrote:

> I have a need, in a Python C extension I am writing, for lists and
> dictionaries with "lazy evaluation" - by which I mean that at least
> some of the values in the lists/dictionaries are "proxy objects"
> which, rather than returning as themselves, should return the thing
> they are a proxy for when retrieved. This is because retrieving
> the proxied objects is expensive and only a small minority of them
> will actually be accessed, so retrieving them all before they are
> actually accessed is massively inefficient.

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).

Tim Delaney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list