Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79725

Re: Lazy-evaluation lists/dictionaries

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 <timothy.c.delaney@gmail.com>
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 <slrnm4q0ej.p8n.jon+usenet@frosty.unequivocal.co.uk>
References <slrnm4q0ej.p8n.jon+usenet@frosty.unequivocal.co.uk>
Date Mon, 27 Oct 2014 07:36:09 +1100
Subject Re: Lazy-evaluation lists/dictionaries
From Tim Delaney <timothy.c.delaney@gmail.com>
To Python-List <python-list@python.org>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15199.1414356081.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 27 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 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

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Lazy-evaluation lists/dictionaries Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2014-10-26 14:14 +0000
  Re: Lazy-evaluation lists/dictionaries Tim Delaney <timothy.c.delaney@gmail.com> - 2014-10-27 07:36 +1100
    Re: Lazy-evaluation lists/dictionaries Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2014-10-27 15:11 +0000
  Re: Lazy-evaluation lists/dictionaries Terry Reedy <tjreedy@udel.edu> - 2014-10-26 18:41 -0400
    Re: Lazy-evaluation lists/dictionaries Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2014-10-27 15:03 +0000

csiph-web