Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'sep': 0.09; 'looked': 0.10; '(the': 0.15; '(also': 0.16; '10:13': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'roy': 0.16; 'string': 0.17; 'wrote:': 0.17; 'certainly': 0.17; 'thu,': 0.17; 'obviously': 0.18; 'received:209.85.214.174': 0.21; 'testing': 0.24; 'header:In-Reply-To:1': 0.25; 'message- id:@mail.gmail.com': 0.27; 'all.': 0.28; "d'aprano": 0.29; 'equality': 0.29; 'steven': 0.29; 'case,': 0.29; 'character': 0.29; 'no,': 0.29; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'compare': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'application': 0.40; 'header:Received:5': 0.40; 'first': 0.61; 'smith': 0.71; 'article': 0.78; '(every': 0.84 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:to :content-type; bh=wGOqr0Ygbj9v8AfpQzT5QSQhSKCjqBiD/txPrFHeGL4=; b=PSJB2A7w2OqUMuqRl4FJVAyXqarv9VBcXZ8EUVIJUDvoGoywaUSlTMDXjO5X420MS7 7Td3VHDBBKGf2eIbHEB5uTvyahCBZco0xnozNpGZjbPQMXWN3KOaY8a7IoPxDPvRGVLq MXcDV6u22pKPMuaYc5QFIHf4HBum2HpISpcDj9jTOk5ALAX9COqKr7aiy3rkSdftNH33 NK+DGNu+7y/6pwipVF0Y4rYgy415NKBjA5CAWmJTsk4id4747TrV42q4adh08po/sdqs 56uObauKRyLJFay2bbSECP/bURBpbQbQgsKAPsK28Jhyau5gA9QZmfclmlZFp5D2oQcq vuQw== MIME-Version: 1.0 In-Reply-To: References: <504564ba$0$29978$c3e8da3$5496439d@news.astraweb.com> <504761ef$0$29981$c3e8da3$5496439d@news.astraweb.com> <50477cbb$0$29981$c3e8da3$5496439d@news.astraweb.com> <50485fca$0$29977$c3e8da3$5496439d@news.astraweb.com> Date: Thu, 6 Sep 2012 22:29:09 +1000 Subject: Re: Comparing strings from the back? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 1346934558 news.xs4all.nl 6941 [2001:888:2000:d::a6]:53328 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28586 n Thu, Sep 6, 2012 at 10:13 PM, Roy Smith wrote: > In article <50485fca$0$29977$c3e8da3$5496439d@news.astraweb.com>, > Steven D'Aprano wrote: > >> In any case, the *worst* case for string equality >> testing is certainly O(N) (every character must be looked at), and the >> *best* case is O(1) obviously (the first character fails to match). > > The best case is O(0), if either string is empty (ducking and running). No, O(0) would be when the application decides not to compare at all. ChrisA (also ducking)