Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Oscar Benjamin Newsgroups: comp.lang.python Subject: Re: Detecting repeated subsequences of identical items Date: Thu, 21 Apr 2016 15:30:36 +0100 Lines: 33 Message-ID: References: <571843f9$0$1585$c3e8da3$5496439d@news.astraweb.com> <5718c457$0$1605$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de rQRv9DVd5IQnXDGc0KKfRQ/d8uI/eZcVNnevKdEBFtzg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'overflow': 0.07; 'see.': 0.07; 'cc:addr:python-list': 0.09; '22,': 0.09; 'benjamin': 0.09; 'exceptions,': 0.09; 'finite': 0.09; 'exception': 0.13; 'stack': 0.13; 'def': 0.13; '2016': 0.16; '<--': 0.16; 'cc:name:python list': 0.16; 'hits': 0.16; 'problem).': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sequence.': 0.16; 'subject:Detecting': 0.16; 'wrote:': 0.16; 'have:': 0.18; '(not': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'bit': 0.23; 'header:In-Reply-To:1': 0.24; 'chris': 0.26; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'sequence': 0.27; 'usually': 0.33; 'received:google.com': 0.35; 'but': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; "won't": 0.38; 'received:209': 0.38; 'end': 0.39; 'goes': 0.39; "you'll": 0.61; 'leading': 0.61; 'leaving': 0.63; 'limit': 0.65; 'here': 0.66; 'increasing': 0.76; 'oscar': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=RNmYq6eZWVrzY+zhC+1POsQ/ynXJ6gWidoU7SnhEASU=; b=vexI77Yp9M/iKiwC0pTDQ3YZr2TMklyc5F/I/XTgVKwk45Y67GFez7WMjnKUMyZo+C yNpbDquPP8kVRRm6+6hqoL45yA7jWIQtvNUBIQOeVgyexSfs+I+GC9OXY/TVIM9JCTDf SK1uczxu0kBsbcvcknyoCfpO9RqbVyWKuq5xi92IBkEEYRc2rtTGwzqoWR+ebYAnyfRn NFjUKIePaEoHpqazUckyJezuUZOC1LlVyQM9TV7/jI/ZBM4BR2bGKQxiTNsqUEdJOJOq ALRa1FIZHhncGfwMjqX8qubEtVOOJ+NAhesuhANZlbP/ICfK/NuCs7vyAnF+5hXZlPrs BdkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=RNmYq6eZWVrzY+zhC+1POsQ/ynXJ6gWidoU7SnhEASU=; b=Z+r4wmtimSoMCJTfOS67+ZN4okZHRiXqGe4WcKCQMv4esk2GrAP0dzl5NHkHYLjDia K5iGDZaCHO3ULrBXFgnOp/TzzRSI2CXpLl8YCEsTAkut4dX0MftgFpu4r+YmChz9n92+ mprDJ94fjmvNZ1dUX3JjzvHUzxLyPPqfWrwfAjFkhMN2kR2H6M13bKRBd7nmFxv9pVWp tIXbzcj8BuWlLuVxwW7SpRTZPhi9ip+dyzF7Nz5CnDygooQqDOt38P2Y/NaLhr56XA7C 7TVzA0QRxo3/EuucdN3LsTwlYCAJbXn6HQxQxsV2kjyad57tKpAY0oxxhlmyHUNdO467 oWkA== X-Gm-Message-State: AOPr4FUmyzmA94c16Z0wNLKYjsxTDfNPaAObHWBUlsqQh3fV0hs8GQI8ae5uYXk3ujY+1oCgnm7vkap0jTdX6Q== X-Received: by 10.25.15.228 with SMTP id 97mr4575773lfp.126.1461249055814; Thu, 21 Apr 2016 07:30:55 -0700 (PDT) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 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: X-Mailman-Original-References: <571843f9$0$1585$c3e8da3$5496439d@news.astraweb.com> <5718c457$0$1605$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:107454 On 21 April 2016 at 15:12, Chris Angelico wrote: > On Fri, Apr 22, 2016 at 12:01 AM, Oscar Benjamin > wrote: >> In the recursive stack overflow case what you'll usually have is >> >> 1) A few frames leading up to the start of recursion >> 2) A long repetitive sequence of frames >> 3) A few frames at the end showing how the exception was ultimately triggered. >> >> You just need to find the cycle that makes that big long sequence. > > If the stack got overflowed, there won't usually be a part 3, as part > 2 is the bit that hits sys.recursionlimit (unless increasing the > recursion limit by a finite number would solve the problem). For other > exceptions, yes, this is what you'd see. If you have: def f(x): return g(x+1) def g(x): x = h(x) # <-- stack can overflow inside here return f(x+1) # etc. So you have a long sequence that goes f, g, f, g but at the end the stack can overflow while (not recursively) calling h leaving a small non-cyclic part at the end. -- Oscar