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


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

RE: len() on mutables vs. immutables

Started by"Prasad, Ramit" <ramit.prasad@jpmorgan.com>
First post2012-10-18 20:26 +0000
Last post2012-10-18 20:26 +0000
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 "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-10-18 20:26 +0000

#31683 — RE: len() on mutables vs. immutables

From"Prasad, Ramit" <ramit.prasad@jpmorgan.com>
Date2012-10-18 20:26 +0000
SubjectRE: len() on mutables vs. immutables
Message-ID<mailman.2473.1350592004.27098.python-list@python.org>
Ian Kelly wrote:
> Sent: Thursday, October 18, 2012 2:39 PM
> To: Python
> Subject: Re: len() on mutables vs. immutables
> 
> 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.

That is what I was thinking "should" happen. Thanks for the 
clarification Ian.


Ramit Prasad


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

[toc] | [standalone]


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


csiph-web