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


Groups > comp.lang.python > #42936

Re: Trying to understand working with dicts

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Trying to understand working with dicts
Date 2013-04-06 15:20 -0400
Organization > Bestiaria Support Staff <
References <CAFqGZRGJ51=zJ=KAfggW99QyjF6NvbX8FjBued0U9HMcGN3AMw@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.205.1365276052.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, 5 Apr 2013 18:04:03 +0530, inshu chauhan <insideshoes@gmail.com>
declaimed the following in gmane.comp.python.general:

> Hello everyone,
> 
> Here in my part of the code where cc is a dictionary. I want to understand
> what actually cc.iterkeys() and cc[k] actually doing.
> I am already reading
> http://docs.python.org/2/library/stdtypes.html#dict.items
> and http://www.tutorialspoint.com/python/python_dictionary.htm but still
> not very clear.
> 
> cc = Computesegclass(segimage, refimage)
>     for k in sorted(cc.iterkeys()):

	Off hand, .iterkeys() is not doing much useful here. Most all
"iterator" systems are designed to generate/fetch the next entry WHEN
NEEDED. But you are passing it to a sort routine, and I don't know of
any lazy sort algorithm that can return the next /sorted/ item without
having processed all the items -- so that is effectively the same as 
sorted(cc.keys())



-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


Thread

Re: Trying to understand working with dicts Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-04-06 15:20 -0400

csiph-web