Lazy-evaluation lists/dictionaries

Tim Delaney timothy.c.delaney at gmail.com
Sun Oct 26 16:36:09 EDT 2014


On 27 October 2014 01:14, Jon Ribbens <jon+usenet at unequivocal.co.uk> 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: <http://mail.python.org/pipermail/python-list/attachments/20141027/c1282aa6/attachment.html>


More information about the Python-list mailing list