Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63070
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subsequent': 0.05; 'element': 0.07; 'assuming': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; '[none]': 0.16; 'discussion.': 0.16; 'elements,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'roy': 0.16; 'sentinel': 0.16; 'singleton': 0.16; 'subclass': 0.16; 'elements': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'have:': 0.19; 'example': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'shown': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'usually': 0.31; 'post.': 0.31; 'trivial': 0.31; 'quite': 0.32; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'possible': 0.36; 'list': 0.37; 'minimum': 0.38; 'ahead': 0.38; 'expect': 0.39; 'does': 0.39; 'space': 0.40; 'most': 0.60; 'maximum': 0.63; 'smith': 0.68; 'article': 0.77; 'filling': 0.78; 'to:none': 0.92 |
| 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:cc :content-type; bh=bOrzwMspAdYdhQUImG6E+7dp5TSVhWh4PCClDAEwSuA=; b=hjG2QcP+hfy8Mj2ZBAKVTZyLfUqbeOcajhjE3WYGEW1Rxz7I6K3G7dO+c3t1SPneGW RFegr3lKSMO8zmqSeQdhHxAvb66lZtIL4YbcREy7Ano9ViE9kJHUIPsqgZV0Jj6A3Zcq +YrYaklgC8NOkXoDu83ITOS5cmbrhN/alpw7h3CNZZfnigMTelqmoL3DcpUEw+e7UcO/ 9kd3kGnBKsJ5Pa/cW727N+C/GN03g+I8W2dwzbvtrvXoK+Vlx8xZrYnYE7onYdNyevVO KiNM/Y49DOstROxxih7Y31H4zBOUiwt5WZvKItkEvEYEpWwmo+X/gNhdfzFByfSNovlM eqeg== |
| MIME-Version | 1.0 |
| X-Received | by 10.66.129.133 with SMTP id nw5mr49764226pab.98.1388764676701; Fri, 03 Jan 2014 07:57:56 -0800 (PST) |
| In-Reply-To | <roy-6F59F6.10514703012014@news.panix.com> |
| References | <CACwCsY5P47-dB1NLQTUTQ=0aF6B+-M3y4hCxcUGmcVmHM8=-xQ@mail.gmail.com> <mailman.4853.1388763434.18130.python-list@python.org> <roy-6F59F6.10514703012014@news.panix.com> |
| Date | Sat, 4 Jan 2014 02:57:56 +1100 |
| Subject | Re: Creating a list with holes |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.4859.1388764686.18130.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1388764686 news.xs4all.nl 2976 [2001:888:2000:d::a6]:50606 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:63070 |
Show key headers only | View raw
On Sat, Jan 4, 2014 at 2:51 AM, Roy Smith <roy@panix.com> wrote: > In article <mailman.4853.1388763434.18130.python-list@python.org>, > Chris Angelico <rosuav@gmail.com> wrote: > >> Alternatively, if you expect to fill in most of the elements, it's >> possible you'd be happier working with a subclass of list that >> auto-expands by filling in the spare space with a singleton meaning >> "no element here". > > And, if you know ahead of time the maximum number of elements you will > ever have: > > x = [None] * max_count > > will preallocate them all with a minimum of fuss. Yes, as I use in the trivial example in the subsequent post. But as a general solution this is usually insufficient. (Whether or not None is valid as a sentinel is, of course, quite orthogonal to the discussion. I avoided assuming that it was, the OP's now shown that it does seem to be.) ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: Creating a list with holes Chris Angelico <rosuav@gmail.com> - 2014-01-04 02:37 +1100
Re: Creating a list with holes Roy Smith <roy@panix.com> - 2014-01-03 10:51 -0500
Re: Creating a list with holes Chris Angelico <rosuav@gmail.com> - 2014-01-04 02:57 +1100
csiph-web