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


Groups > comp.lang.python > #31681 > unrolled thread

Re: len() on mutables vs. immutables

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2012-10-18 13:38 -0600
Last post2012-10-18 13:38 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: len() on mutables vs. immutables Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-18 13:38 -0600

#31681 — Re: len() on mutables vs. immutables

FromIan Kelly <ian.g.kelly@gmail.com>
Date2012-10-18 13:38 -0600
SubjectRe: len() on mutables vs. immutables
Message-ID<mailman.2471.1350589145.27098.python-list@python.org>
On Thu, Oct 18, 2012 at 1:18 PM, Prasad, Ramit
<ramit.prasad@jpmorgan.com> wrote:
> Why does pointer arithmetic work for dicts? I would think the position
> of a value would be based on the hash of the key and thus "random" for
> the context of this conversation.

It doesn't.  len() on CPython dicts is O(1) because the dict keeps
track of how many items it contains.  It needs to do this anyway so
that it can determine when to grow the internal hash table.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web