Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:Python': 0.05; 'that?': 0.05; 'dict': 0.09; '"from': 0.16; 'coordinates': 0.16; 'lookups': 0.16; 'nearest': 0.16; 'obj1': 0.16; 'obj2': 0.16; 'wrote:': 0.17; 'subject:Issue': 0.17; 'skip:p 30': 0.20; 'import': 0.21; 'random': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'select': 0.26; 'am,': 0.27; 'subject:list': 0.28; 'run': 0.28; 'faster,': 0.29; 'obj': 0.29; 'objects': 0.29; 'class': 0.29; 'code': 0.31; 'system,': 0.32; 'to:addr:python-list': 0.33; "can't": 0.34; 'wrong': 0.34; 'list': 0.35; 'fastest': 0.35; 'but': 0.36; 'be.': 0.36; 'email addr:python.org': 0.36; 'test': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'build': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'think': 0.40; 'subject:, ': 0.61; '2.7.1': 0.84; 'intuit': 0.84; 'received:98.172': 0.84; 'email name:python-list-request': 0.91; 'imagine': 0.96 Date: Thu, 04 Oct 2012 08:20:00 -0400 From: Benjamin Jessup Organization: ABZ, Inc. User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Python-list Digest, Vol 109, Issue 20 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1349353254 news.xs4all.nl 6903 [2001:888:2000:d::a6]:60067 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30718 On 10/4/2012 12:20 AM, python-list-request@python.org wrote: > How do you know that? > > No offence, but if you can't even work out whether lookups in a dict or a > list are faster, I can't imagine why you think you can intuit what the > fastest way to retrieve the nearest neighbours would be. Whats wrong with the test below? # randomly select matrix coordinates to look-up from random import randrange test_coords = [] for i in range(1000): x = randrange(2400); y = randrange(2400); test_coords.append((x, y)) # build objects class Object():pass obj1 = Object(); obj2 = Object(); obj1.up = obj2 # build some test code from timeit import Timer setup = "from __main__ import test_coords, obj1, obj2" t = Timer("for p in test_coords: obj = obj1.up", setup) # run the test code print(min(t.repeat(number=10000, repeat=7))) import platform print(platform.python_version()) On my system, I get: 0.719622326348 2.7.1