Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'duplicate': 0.07; 'string': 0.09; 'booth': 0.09; 'strings.': 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; 'readable': 0.16; 'storing': 0.16; 'string).': 0.16; 'subject: \n ': 0.16; 'subject:dictionaries': 0.16; 'wrote:': 0.18; 'otherwise,': 0.22; 'creating': 0.23; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'sets': 0.30; '(on': 0.31; 'away.': 0.31; 'keys': 0.31; 'overhead': 0.31; 'but': 0.35; "didn't": 0.36; 'charset:us-ascii': 0.36; 'being': 0.38; 'skip:. 20': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'space': 0.40; 'matter': 0.61; 'save': 0.62; 'received:50.22': 0.84 Date: Tue, 25 Feb 2014 16:36:08 -0600 From: Tim Chase To: python-list@python.org Subject: Re: intersection, union, difference, symmetric difference for dictionaries In-Reply-To: References: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393367740 news.xs4all.nl 2968 [2001:888:2000:d::a6]:44339 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67072 On 2014-02-25 22:21, Duncan Booth wrote: > > It would save some space if I didn't have to duplicate all the > > keys into sets (on the order of 10-100k small strings), instead > > being able to directly perform the set-ops on the dicts. But > > otherwise, it was pretty readable & straight-forward. > > > It doesn't matter whether they were small strings or full-length > novels, creating a set from a dict doesn't duplicate any strings. pre-my-new-learning-about .viewkeys() it sounds like set(my_dict) would have the overhead of storing an additional reference to a string per set-entry (rather than duplicating every string). With .viewkeys()/.keys(), it sounds like that overhead would go away. -tkc