Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.053 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'algorithm': 0.03; 'subject:file': 0.07; 'dict': 0.09; 'sure,': 0.09; 'cc:addr :python-list': 0.10; 'read.': 0.13; 'entries,': 0.16; 'wrote:': 0.17; 'saying': 0.18; 'latter': 0.22; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'cc:addr:gmail.com': 0.27; 'order.': 0.27; 'probably': 0.29; 'figure': 0.30; 'print': 0.32; 'faster': 0.35; 'so,': 0.35; 'pm,': 0.35; 'cc:no real name:2**1': 0.36; 'uses': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'easier': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'harder': 0.65; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'actually,': 0.84; 'difference.': 0.84; 'different.': 0.84; 'received:74.208.4.194': 0.84; 'hundred': 0.95 Date: Thu, 09 Aug 2012 17:47:45 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Roman Vashkevich Subject: Re: save dictionary to a file without brackets. References: <930ab3d8-4ab9-446d-9970-ee811eb70a44@googlegroups.com> <50241F14.2060209@tim.thechases.com> <36EA3847-6713-4C12-B47B-9B5E10325F00@gmail.com> <502429C3.5000600@tim.thechases.com> <583C055C-9E99-4EAC-8F3A-D578C399826E@gmail.com> In-Reply-To: <583C055C-9E99-4EAC-8F3A-D578C399826E@gmail.com> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:i7hjnS0dpVTVXTRgxABJI5pMtjMVNDAcbC9bYeTB7Kf ZLNqAzzSDZuQfg4XUcJ6f4blwQjXebLUYA4XNgHZBx9GhMHCEd TRu5FWyh0u2LwuRO+0gKO7KYdGdt/i6R0gk8ZSRi0n1JELw66w Rnnm2b50ksjDZL8HTFu27gqf2cQHCT1EMoZA2+ZeGG+Vlhj2Sp BHYIlyeaZiHuKj3Gw+axTTJJVBPxfg7AGzfzcoPolzYGzzmK9N G7/pApOUzXp8hOARv7iIU2p4XUxraU5DusJT2Rtml34PGRrL9H Z3l8kAIVb0I6Nu3lTAB2x+7VRfhyTQYdomH4hdU3maMmIQWUg= = Cc: python-list@python.org, giuseppe.amatulli@gmail.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: d@davea.name 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1344548888 news.xs4all.nl 6850 [2001:888:2000:d::a6]:45524 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26819 On 08/09/2012 05:34 PM, Roman Vashkevich wrote: > Actually, they are different. > Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred thousand entries, and you will feel the difference. > Dict uses hashing to get a value from the dict and this is why it's O(1). Sure, that's why for key in dict: print key[0], key[1], dict[key] is probably slower than for (edge1, edge2), cost in d.iteritems(): # or .items() print edge1, edge2, cost So, the latter is both faster and easier to read. Why are you arguing against it? Also, please stop top-posting. It's impolite here, and makes it much harder to figure out who is saying what, in what order. -- DaveA