Path: csiph.com!news.mixmin.net!news.albasani.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Antoon Pardon Newsgroups: comp.lang.python Subject: Re: how to convert code that uses cmp to python3 Date: Sat, 9 Apr 2016 17:24:24 +0200 Lines: 18 Message-ID: References: <57064D0D.1030701@rece.vub.ac.be> <5706C961.2000009@rece.vub.ac.be> <57075F43.7060004@rece.vub.ac.be> <85fuuw5ypl.fsf@benfinney.id.au> <5707B2CE.1010407@rece.vub.ac.be> <5707BE18.1050805@rece.vub.ac.be> <5708C8B0.6050904@rece.vub.ac.be> <85twjb3su5.fsf@benfinney.id.au> <570910E2.3030400@rece.vub.ac.be> <57091EA8.4080803@rece.vub.ac.be> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de yVjMM7WNn82o5uynWqxCGQojVWIAlMKcERDGTrwZSURA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.079 X-Spam-Evidence: '*H*': 0.84; '*S*': 0.00; 'so?': 0.07; 'subject:code': 0.07; 'dict': 0.09; 'lookups': 0.16; 'naive': 0.16; 'received:192.168.1.4': 0.16; 'received:adsl- dyn.isp.belgacom.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:python3': 0.16; 'tree': 0.18; 'keys': 0.22; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'chris': 0.26; 'branches': 0.29; 'comparison': 0.29; 'subject:that': 0.29; 'received:be': 0.30; 'probably': 0.31; "can't": 0.32; 'values.': 0.33; 'case,': 0.34; 'structure': 0.34; '(and': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'end': 0.39; 'data': 0.39; 'easily': 0.39; 'takes': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'provide': 0.61; 'charset:windows-1252': 0.62; 'matter': 0.63; 'between': 0.65; 'account': 0.66; 'fact,': 0.67; 'angelico:': 0.84; 'answer,': 0.84; 'pardon': 0.84; 'received:195.238': 0.84; 'schreef': 0.84 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CbAABnHglX/2LF9VENUL9bAQ2Bc4YNAoFiFAEBAQEBAQGFTgEBAwF4EQshDAoPCQMCAQIBRRMIAogbp2GNVoRbAQEIAh6GIYRLhH4NhQoBBJgEgVSMOI8NjyYeAQGEK4oWAQEB User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <57091EA8.4080803@rece.vub.ac.be> X-Mailman-Original-References: <57064D0D.1030701@rece.vub.ac.be> <5706C961.2000009@rece.vub.ac.be> <57075F43.7060004@rece.vub.ac.be> <85fuuw5ypl.fsf@benfinney.id.au> <5707B2CE.1010407@rece.vub.ac.be> <5707BE18.1050805@rece.vub.ac.be> <5708C8B0.6050904@rece.vub.ac.be> <85twjb3su5.fsf@benfinney.id.au> <570910E2.3030400@rece.vub.ac.be> Xref: csiph.com comp.lang.python:106737 Op 09-04-16 om 16:41 schreef Chris Angelico: > > In this case, you're likely to end up with large branches of your tree > that have the same prefix. (And if you don't, your iterations are all > going to end early anyway, so the comparison is cheap.) A data > structure that takes this into account will out-perform the naive > comparison model every time. In fact, a simple dict will probably > out-perform your tree; So? I need a structure that can easily give me an answer to the following: Given key1 and key2 what are the the keys between them with their corresponding values. As long as a dict can't provide me with that answer, it doesn't matter that it will out perform lookups in my trees. -- Antoon Pardon