Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'themselves,': 0.09; 'api': 0.11; 'python': 0.11; 'api,': 0.16; 'dictionaries': 0.16; 'massively': 0.16; 'retrieving': 0.16; 'subject:dictionaries': 0.16; 'which,': 0.16; 'wrote:': 0.18; 'module': 0.19; 'proxy': 0.24; 'extension': 0.26; 'least': 0.26; 'subject:/': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'message-id:@mail.gmail.com': 0.30; 'lists': 0.32; 'to:name :python-list': 0.33; 'objects': 0.35; 'subject:lists': 0.35; 'received:google.com': 0.35; 'returning': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'rather': 0.38; 'expensive': 0.39; 'to:addr:python.org': 0.39; 'such': 0.63; 'writing,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=kPzy9k5iLcso9EhHhASb45JCLehSqrRDgwPTTRXX1+0=; b=ezVXLisRKVbeMJxw6yVxsb+dcJ5XALk+SmXCb4drX7lpSSxMCuUMmxBQwQ5UB64IQJ OHBO89wC+RopxAHPkT0rUIisnj3Gb41RDE8pHZYYhN0iQhf/Hcjm/kQigqu59+mnjwe5 zG1sTS6m3p4u3bnUkev7JEQE41OTEdKvc5oI1FsMrAyqg7/Wg/v9vGkR2o3hgmy40Luk OIlq2xZ3diTlzqCwMfc0sl4Wfly4Iup96RTJyOcjbXU5kdZAwUXD/D/WiD+OmUtHhFRt P1RURELpc6fb3bUMyAeiPr6epXTrwmKg//4wQ7wipRaowHaFgUNZrLDXaMGOFaXtuT9A 4Pdg== MIME-Version: 1.0 X-Received: by 10.182.142.10 with SMTP id rs10mr9621349obb.36.1414355769146; Sun, 26 Oct 2014 13:36:09 -0700 (PDT) In-Reply-To: References: Date: Mon, 27 Oct 2014 07:36:09 +1100 Subject: Re: Lazy-evaluation lists/dictionaries From: Tim Delaney To: Python-List Content-Type: multipart/alternative; boundary=001a11c2df3434c5500506595d86 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 48 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414356081 news.xs4all.nl 2837 [2001:888:2000:d::a6]:53414 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79725 --001a11c2df3434c5500506595d86 Content-Type: text/plain; charset=UTF-8 On 27 October 2014 01:14, Jon Ribbens 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 --001a11c2df3434c5500506595d86 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On 2= 7 October 2014 01:14, Jon Ribbens <jon+usenet@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 lea= st
some of the values in the lists/dictionaries are "proxy objects"<= br> 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 weakr= ef module for an API that may be suitable for such proxy objects (if you us= ed the same API, that would also allow you to transparently use weakrefs in= your lists/dicts).

Tim Delaney=C2=A0
<= /div>
--001a11c2df3434c5500506595d86--