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


Groups > comp.lang.python > #63666

L[:]

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.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 <fomcl@yahoo.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status UNSURE 0.309
X-Spam-Level ***
X-Spam-Evidence '*H*': 0.50; '*S*': 0.12; '(so': 0.07; 'explanation': 0.09; 'here?': 0.09; 'python': 0.11; '#python': 0.16; '2.7.3': 0.16; 'underlying': 0.16; 'starts': 0.20; '>>>': 0.22; 'second': 0.26; 'forgot': 0.30; 'that.': 0.31; 'object.': 0.31; 'sep': 0.31; 'thanks!': 0.32; 'could': 0.34; 'but': 0.35; 'done': 0.36; 'system,': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'received:67.195': 0.60; 'received:98.137': 0.60; 'increased': 0.61; 'simply': 0.61; 'name': 0.63; 'more': 0.64; 'received:gq1.yahoo.com': 0.68; 'received:mail.gq1.yahoo.com': 0.68; 'below.': 0.71; 'apart': 0.72; 'idiom': 0.84; 'received:bullet.mail.gq1.yahoo.com': 0.84; 'us?': 0.84; '2013,': 0.91; 'medicine,': 0.91; 'education,': 0.96
X-Yahoo-Newman-Property ymail-3
X-Yahoo-Newman-Id 502720.58726.bm@omp1001.mail.gq1.yahoo.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1389375507; bh=fuPc5ebnR9yII6eVkkpkHZCyyALaaMj6xmcZmjARxzk=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=ANEoGhbCZcQQQrY6NW4r4jfXlHBz5P/5SU611mEVddZgiP2gi3KsQFAD4i1N4Dh4sUSvddINl5mezR64xB5HKmbeTLcbwI1hJtOrRbWJsO0w1CrzQQyFGlulSbyxoloHxo98eCXKBKK+WcjQrr7VBYJspPXy/KShaBq588EA9BI=
DomainKey-Signature a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=xhCi6qkInYIfxiQh6ghbvYkUS8nQlB9a5JiQQwJUOwEXZJtl+qqyttmliMSdV3SZh050CgcTiIgU7HNVL4KUEPT4eLNtEziG+U6eOptqtQG6v+xn7p7y+IVYd8FU4LXODEbEe40C8jnqwH4L3EkftqI2ihHa0raCPlVqlA5dY9M=;
X-YMail-OSG R4fyQT0VM1k5HflLUqwZ_z20MezafsfgICvf266rOAX0TTA QyqENiDlcjc0BR4lEzHSvlVuKi7nbG2.0f3Q0I9iL1AYIx1MGaTwRbljjtB8 CTFtcLPCNpGx2jDm5j3R0BCQRo7Cl7ddVV5dcihstjrpVQuyqMPft47.oiIK nqR6E2O2sOC9x7EQ4Fx5PExikkGQr.MJetXbMwpP5fxo9ZY0JcTgW9XOxAvM hO.7WWPrToQVzK2DYQgxJroPpHhaeYjdtHdcf86J3IjwtEO9miXfBP1Tw0wa LYUnDAwDm.LYs1getY8ihjlzQJg2T0f.fUOKHAKfCXCz3vnsXHuCpl8tJF7J hWC3lJeSo441iNOZLGhsoszjD5iYUEFPChh1S4pxziZrGQl2hz_ECQccwTxx lxsHfI.yDg3W4ou.EdG7Jr0Mj4V06twjOcnfTJXyz1g3pLW68P1HQOF8UCUy xGCrBGCinKo5LR2X4RZT_xi.wMI81Zj66sQpdKXl75ENOpji5U2OWt_xRorl sZ29VijclcSV99ScHKDDDRHhAoLV_ZaI3HYFvx0R08i4dqA70_ChgIvkhPaN dLoW5suc-
X-Rocket-MIMEInfo 002.001, SW4gUHl0aG9uIENvb2tib29rLCBvbmUgb2YgdGhlIGF1dGhvcnMgKEkgZm9yZ290IHdobykgY29uc2lzdGVudGx5IHVzZWQgdGhlICJMWzpdIiBpZGlvbSBsaWtlIGJlbG93LiBJZiB0aGUgc2Vjb25kIGxpbmUgc2ltcGx5IHN0YXJ0cyB3aXRoICJMID0iIChzbyBubyAiWzpdIikgb25seSB0aGUgbmFtZSAiTCIgd291bGQgYmUgcmVib3VuZCwgbm90IHRoZSB1bmRlcmx5aW5nIG9iamVjdC4gVGhhdCB3YXMgdGhlIGF1dGhvcsWbIGV4cGxhbmF0aW9uIGFzIGZhciBhcyBJIGNhbiByZW1lbWJlci4gSSBkbyBub3QBMAEBAQE-
X-Mailer YahooMailClassic/387 YahooMailWebService/0.8.172.614
Date Fri, 10 Jan 2014 09:38:27 -0800 (PST)
From Albert-Jan Roskam <fomcl@yahoo.com>
Subject L[:]
To Python <python-list@python.org>
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding quoted-printable
X-Mailman-Approved-At Fri, 10 Jan 2014 21:59:29 +0100
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.5305.1389387570.18130.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389387571 news.xs4all.nl 2928 [2001:888:2000:d::a6]:39321
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63666

Show key headers only | View raw


In Python Cookbook, one of the authors (I forgot who) consistently used the "L[:]" idiom like below. If the second line simply starts with "L =" (so no "[:]") only the name "L" would be rebound, not the underlying object. That was the authorÅ› explanation as far as I can remember. I do not get that. Why is the "L[:]" idiom more memory-efficient here? How could the increased efficiency be demonstrated?

#Python 2.7.3 (default, Sep 26 2013, 16:38:10) [GCC 4.7.2] on linux2
>>> L = [x ** 2 for x in range(10)]
>>> L[:] = ["foo_" + str(x) for x in L]


Thanks!


Regards,

Albert-Jan



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a 

fresh water system, and public health, what have the Romans ever done for us?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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


Thread

L[:] Albert-Jan Roskam <fomcl@yahoo.com> - 2014-01-10 09:38 -0800

csiph-web