Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'doing?': 0.09; 'cc:addr :python-list': 0.11; '23,': 0.16; 'algorithmic': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lookups': 0.16; 'looping': 0.16; 'numpy': 0.16; 'unlikely': 0.16; 'wrote:': 0.18; 'looked': 0.18; 'trying': 0.19; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'certainly': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'performing': 0.26; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'possibility': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'apparently': 0.31; 'sep': 0.31; 'them?': 0.31; 'themselves': 0.32; 'operations': 0.35; 'received:google.com': 0.35; 'crazy': 0.36; 'doing': 0.36; 'changing': 0.37; 'checks': 0.38; 'structure': 0.39; 'kind': 0.63; 'more': 0.64; 'taking': 0.65; 'between': 0.67; 'collision': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=i28ioOT1z5StVVbbEJFtWOSco7QaUU5Qmtw/ZzgJyDI=; b=j+KHapNNnz8XxVatr65ufevSflWrY56tBXwYVvTx71GTVCwkgfCucoSIG2dkd+ZQ+7 lBIFiAf+7VZheoWDx89/poMwpzJcK1AhTvV3w4PTS1wHp4PZVR949lqN0kRFv81X4jaV BCcCV3H0cU1vQea3Modw2rAsKLGoIAdM/WvCG80ky6W3pDhqJWKF/8dpHqSXQwFoGvNO ZuHbJA0JBM6cCX3vru2w7L3PDEozJHEJKJxrFj5/J93p6xZgbj+KJGEFXZtPG8D1l/3n vGeeZbh2XILZqEw9tivaZhBCIolC1Cf0aqxYm9UOQQ0Y+wKiazqjLnVR89h0Ev9l86Dx TEbQ== MIME-Version: 1.0 X-Received: by 10.50.117.65 with SMTP id kc1mr16095033igb.34.1411405870000; Mon, 22 Sep 2014 10:11:10 -0700 (PDT) In-Reply-To: <521ef86a-df52-4a49-8562-6312273a8c07@googlegroups.com> References: <521ef86a-df52-4a49-8562-6312273a8c07@googlegroups.com> Date: Tue, 23 Sep 2014 03:11:09 +1000 Subject: Re: Comparison From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1411405879 news.xs4all.nl 2858 [2001:888:2000:d::a6]:46707 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78168 On Tue, Sep 23, 2014 at 2:57 AM, LJ wrote: > Quick question here. In the code I am working on I am apparently doing a lot of dictionary lookups and those are taking a lot of time. > I looked at the possibility of changing the structure and I found about the numpy structured arrays. > The concrete question is: what would be the difference between using one or the other in terms of performance? meaning looping and performing checks an operations on them? The lookups themselves almost certainly aren't actually taking the time, unless you have some kind of crazy hash collision happening, which is so statistically unlikely that it would have to have come from malice. What's the code doing? What are you trying to accomplish? It's much more likely that you have an algorithmic flaw than a data type inefficiency. ChrisA