Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31673
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <demianbrecht@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; '(of': 0.07; 'indicated': 0.07; 'item.': 0.07; 'bytes,': 0.09; 'minus': 0.09; 'pointers': 0.09; 'str,': 0.09; 'terry': 0.09; 'assume': 0.11; 'cases': 0.15; '(more': 0.16; 'arrays,': 0.16; 'awesome.': 0.16; 'blocks': 0.16; 'bytearrays,': 0.16; 'dig': 0.16; 'len': 0.16; 'reedy': 0.16; 'subtraction': 0.16; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'am,': 0.27; 'possibility': 0.27; 'slot': 0.29; 'source': 0.29; 'helpful': 0.30; 'could': 0.32; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'message-id:@gmail.com': 0.36; 'depends': 0.36; 'totally': 0.36; "i'll": 0.36; 'should': 0.36; 'two': 0.37; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'address': 0.60; 'most': 0.61; 'first': 0.61; 'confirm': 0.64; 'subject:. ': 0.66; 'dangerous': 0.66; 'eyes': 0.69; 'ranges': 0.71; 'is)': 0.84; 'sets,': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=9EEkKPlTS0YQdDj9t5VlnO/DSj3E2ZOJq0tOHwZ0H8I=; b=UgeJNu9l9vYPmYwayN25G2eWZtEsm7D9Mo39MQMZjL8BZe+9LiDQ02225+DGG/AgCc z/P8w8hORef1pZudBG4tfJj46smydO0HOqELQ8pIcP+5cgMQF5LM/ghPWdNYZ3TBoyvH eLCV9XHUmfOhNWVQAB3mfzoxQtGhAoQkWJ8fXKTgR+VtMvXF5olfu7FKdvkm4So2DLVW teDw1wPzGVBn/qYySNBpRpIasRwQoeks8M4nUfQnxg8I5PTjPaWE148XFLjfpt6gLfIy ibk3LwekHajBRzSmH7Cp+buFb1x49zC++n6lxGjvwPftlQszrBhDTvXdgpwVS9WEAZSv SDMg== |
| Date | Thu, 18 Oct 2012 11:42:48 -0700 |
| From | Demian Brecht <demianbrecht@gmail.com> |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: len() on mutables vs. immutables |
| References | <50803B2C.6010900@gmail.com> <k5phqe$2ia$1@ger.gmane.org> |
| In-Reply-To | <k5phqe$2ia$1@ger.gmane.org> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2462.1350585776.27098.python-list@python.org> (permalink) |
| Lines | 16 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1350585776 news.xs4all.nl 6944 [2001:888:2000:d::a6]:53961 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:31673 |
Show key headers only | View raw
On 10/18/2012 11:29 AM, Terry Reedy wrote:> Or the length could be the difference of two pointers -- address of the > first empty slot minus address of first item. That would assume contiguous blocks of memory, which I would find to be rather dangerous (of an assumption that is) in most dynamic cases (obviously totally depends on implementation details). > str, bytes, bytearrays, arrays, sets, frozensets, dicts, dictviews, and > ranges should all return len in O(1) time. That includes the possibility > of a subtraction as indicated above. Awesome. Pretty much what I figured. Of course, I'll have to dig around the source just to confirm this with my own eyes (more just curiosity than anything), so if you know whereabouts to look, it would be most helpful :)
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: len() on mutables vs. immutables Demian Brecht <demianbrecht@gmail.com> - 2012-10-18 11:42 -0700
csiph-web