Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'strings.': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sep': 0.09; 'cases': 0.15; 'limiting': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'unequal': 0.16; 'worst': 0.16; 'string': 0.17; 'wrote:': 0.17; 'differ': 0.17; 'thu,': 0.17; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'wonder': 0.27; 'important.': 0.27; 'header:X-Complaints- To:1': 0.28; "d'aprano": 0.29; 'steven': 0.29; 'to:addr:python- list': 0.33; 'equal': 0.33; 'fail': 0.35; 'subject:?': 0.35; 'received:org': 0.36; 'characters': 0.36; 'two': 0.37; 'systems,': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'most': 0.61; 'first': 0.61; 'interest': 0.62; '(they': 0.84; 'complexity': 0.84; 'angel': 0.93; 'average': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Gelonida N Subject: Re: Comparing strings from the back? Date: Sat, 08 Sep 2012 17:52:10 +0200 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> <504972d1$0$29981$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: unicorn.dungeon.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 In-Reply-To: <504972d1$0$29981$c3e8da3$5496439d@news.astraweb.com> 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347119709 news.xs4all.nl 6854 [2001:888:2000:d::a6]:48905 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28728 On 09/07/2012 06:06 AM, Steven D'Aprano wrote: > On Thu, 06 Sep 2012 06:07:38 -0400, Dave Angel wrote: > > > Also of some interest is the best case: O(1) for unequal strings (they > differ at the first character) and O(N) for equal strings. The worst case is O(N) or N characters the average case is O(1) or two characters. For denial of service attacks or systems, that are NEVER allowed to fail the worst case is important. For most other cases the average complexity counts. However I still wonder for how many applications the complexity of string comparisons would be the limiting factor.