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


Groups > comp.lang.python > #31683

RE: len() on mutables vs. immutables

From "Prasad, Ramit" <ramit.prasad@jpmorgan.com>
Subject RE: len() on mutables vs. immutables
Date 2012-10-18 20:26 +0000
References <50803B2C.6010900@gmail.com> <k5phqe$2ia$1@ger.gmane.org> <5B80DD153D7D744689F57F4FB69AF4741671D06A@SCACMX008.exchad.jpmchase.net> <CALwzid==JD-mxv_okmhfC-nL+Yx8Dj6FYGCyRPGbsL3cmjGt2A@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2473.1350592004.27098.python-list@python.org> (permalink)

Show all headers | View raw


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.  

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


Thread

RE: len() on mutables vs. immutables "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-10-18 20:26 +0000

csiph-web