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


Groups > comp.lang.python > #66390

Re: Generator using item[n-1] + item[n] memory

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.029
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'skip:` 10': 0.07; 'subject:using': 0.09; 'yeah,': 0.09; 'nick': 0.16; 'subject:item': 0.16; 'wrote:': 0.18; 'subject:] ': 0.20; 'seems': 0.21; 'feb': 0.22; 'looks': 0.24; 'gets': 0.27; 'header:In-Reply- To:1': 0.27; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'fri,': 0.33; 'actual': 0.34; 'but': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'next': 0.36; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'previous': 0.38; 'subject:[': 0.39; 'to:addr:python.org': 0.39; 'release': 0.40; "you'll": 0.62; 'forced': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=gCA0c6JTd+ci92pSfabg6abFXw8B81nMH2N1qHBHD0w=; b=YJn01mCu9zBzwVBWah6/HNCT0MkBO8Medf20fMn7G4O+Rq/ddpHYlU7OLZHgUq4SXR TdxHoDy3vxtTsVE44EXm/ArgZKXIhExIVAwToRB+lIe3KCJUO+1pK7INDIPMcJFPTiqc V0JB/KXkQ35w7DtxOeatkmjHoL5JrojquBui/Sa+WxhaFBTx8VY/14K5wP59jyOHeQCI 0+avQzAYY6VkzAXsfESBFu/BHa88mFUIEjfOWYaRU7e7uJFjexF+i0Pnig2DXL9QZxPN RXMWojG3deea0QCNvmBGW12pq7MBgovbn5YvZDhg2niH91WjPNg7RdBYpMip+Ghj7Fs2 nvvw==
X-Received by 10.66.179.143 with SMTP id dg15mr14141694pac.52.1392449262968; Fri, 14 Feb 2014 23:27:42 -0800 (PST)
MIME-Version 1.0
In-Reply-To <CAHkxivccycyvqBsBPJMOTixufiTyv3GNCzU4ELgAUv2F+0EExA@mail.gmail.com>
References <mailman.6952.1392433921.18130.python-list@python.org> <roy-1037EA.22211114022014@news.panix.com> <CAHkxivccycyvqBsBPJMOTixufiTyv3GNCzU4ELgAUv2F+0EExA@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Sat, 15 Feb 2014 00:27:02 -0700
Subject Re: Generator using item[n-1] + item[n] memory
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
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.6973.1392449266.18130.python-list@python.org> (permalink)
Lines 9
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392449266 news.xs4all.nl 2868 [2001:888:2000:d::a6]:35405
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66390

Show key headers only | View raw


On Fri, Feb 14, 2014 at 8:31 PM, Nick Timkovich <prometheus235@gmail.com> wrote:
> OK, now the trick; adding `data = None` inside the generator works, but in
> my actual code I wrap my generator inside of `enumerate()`, which seems to
> obviate the "fix".  Can I get it to play nice or am I forced to count
> manually. Is that a feature?

Yeah, looks like enumerate also doesn't release its reference to the
previous object until after it gets the next one.  You'll just have to
make do without.

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


Thread

Re: Generator using item[n-1] + item[n] memory Roy Smith <roy@panix.com> - 2014-02-14 22:21 -0500
  Re: Generator using item[n-1] + item[n] memory Nick Timkovich <prometheus235@gmail.com> - 2014-02-14 21:31 -0600
  Re: Generator using item[n-1] + item[n] memory Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-15 00:27 -0700
  Re: Generator using item[n-1] + item[n] memory Chris Angelico <rosuav@gmail.com> - 2014-02-15 18:41 +1100
  Re: Generator using item[n-1] + item[n] memory Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-15 11:03 +0000
  Re: Generator using item[n-1] + item[n] memory Peter Otten <__peter__@web.de> - 2014-02-15 12:27 +0100
  Re: Generator using item[n-1] + item[n] memory Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-15 12:28 +0000

csiph-web