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


Groups > comp.lang.python > #61577

Re: grab dict keys/values without iterating ?!

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.026
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'etc).': 0.09; 'subject:keys': 0.09; '-tkc': 0.16; 'dict': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'letter:': 0.16; 'subject:values': 0.16; 'thread,': 0.16; 'wrote:': 0.18; '(the': 0.22; 'initial': 0.24; 'post': 0.26; 'subject:/': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'code': 0.31; "d'aprano": 0.31; 'keys': 0.31; 'steven': 0.31; 'charset:us-ascii': 0.36; 'starting': 0.37; 'to:addr:python-list': 0.38; 'previous': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; '2nd': 0.60; 'first': 0.61; 'dict,': 0.84; 'dict.': 0.84; 'received:50.22': 0.84
Date Wed, 11 Dec 2013 08:30:51 -0600
From Tim Chase <python.list@tim.thechases.com>
To python-list@python.org
Subject Re: grab dict keys/values without iterating ?!
In-Reply-To <52a86c57$0$29992$c3e8da3$5496439d@news.astraweb.com>
References <52A7AB8C.8030700@arcor.de> <52A7AB8C.8030700@arcor.de> <almarsoft.6523303589308130554@news.gmane.org> <mailman.3885.1386762407.18130.python-list@python.org> <52a86c57$0$29992$c3e8da3$5496439d@news.astraweb.com>
X-Mailer Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
X-Get-Message-Sender-Via boston.accountservergroup.com: authenticated_id: tim@thechases.com
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3900.1386772178.18130.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386772178 news.xs4all.nl 2899 [2001:888:2000:d::a6]:60400
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:61577

Show key headers only | View raw


On 2013-12-11 13:44, Steven D'Aprano wrote:
> If necessary, I would consider having 26 dicts, one for each
> initial letter:
> 
> data = {}
> for c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
>     data[c] = {}
> 
> then store keys in the particular dict. That way, if I wanted keys 
> starting with Aa, I would only search the A dict, not the B dict, C
> dict, etc.

That's what the convoluted code does that I put at the end of my
previous post in this thread, only to the Nth degree (the outermost
dict has the first letter which links to a dictionary of the 2nd
level/letter, to the 3rd level/letter, etc).

-tkc

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


Thread

Re: grab dict keys/values without iterating ?! Tamer Higazi <tameritoke2@arcor.de> - 2013-12-11 12:07 +0200
  Re: grab dict keys/values without iterating ?! rusi <rustompmody@gmail.com> - 2013-12-11 05:31 -0800
    Re: grab dict keys/values without iterating ?! Roy Smith <roy@panix.com> - 2013-12-11 09:46 -0500
      Re: grab dict keys/values without iterating ?! rusi <rustompmody@gmail.com> - 2013-12-11 07:08 -0800
      Re: grab dict keys/values without iterating ?! Tim Chase <python.list@tim.thechases.com> - 2013-12-11 09:42 -0600
    Re: grab dict keys/values without iterating ?! Travis Griggs <travisgriggs@gmail.com> - 2013-12-11 09:19 -0800
    Re: grab dict keys/values without iterating ?! Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-11 18:09 +0000
  Re: grab dict keys/values without iterating ?! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-11 13:44 +0000
    Re: grab dict keys/values without iterating ?! Tim Chase <python.list@tim.thechases.com> - 2013-12-11 08:30 -0600
    Re: grab dict keys/values without iterating ?! Ian Kelly <ian.g.kelly@gmail.com> - 2013-12-11 18:02 -0700
    Re: grab dict keys/values without iterating ?! Ian Kelly <ian.g.kelly@gmail.com> - 2013-12-11 18:05 -0700

csiph-web