Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'algorithm': 0.03; 'subject:Python': 0.05; 'runtime': 0.09; 'seen,': 0.09; 'comparable.': 0.16; 'count,': 0.16; 'dictionary,': 0.16; 'seconds.': 0.16; 'subject:3.3': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'code,': 0.18; 'feb': 0.19; 'programming': 0.23; 'header:In- Reply-To:1': 0.25; 'looks': 0.26; 'am,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'chris': 0.28; 'version,': 0.30; 'implement': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'mapping': 0.35; 'especially': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; "didn't": 0.36; 'anything': 0.36; 'optimization': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; "you've": 0.61; 'first': 0.61; 'subject:. ': 0.66; '2013': 0.84; 'subject:Basic': 0.84; 'timings': 0.84; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=MGR7DloqJ2+UClrY/1P6uwwNc0S2l020gKlLUkdy2TM=; b=DhTejOWmlucr2n0iOrHWx31VaeTWXiG3uaI6sXqlsQ6tHbVXdxYzgA+JsThlfkwNE3 QTO2BNlEzT0MwPluGQLUJXd7soFdOQoMYsTdewnT70d8WeiYbUD2Z9snGUU6eOHKBFBz VJyHxLNtudS+0rkaXZ6PHvxkvelm7zyF35LQPHp5iyt2JuqVY+LxlvBVvlSBaC1Nn8ba SA+DUrG8iZaEcvF9cPH+7KZtMPaUFmp/Kv+xqOZTTYOt1nauEXxQ+ugJ8F4PTMQaCkrn y3N+tW+BxwIafswPtsawyq+xbf0P5UvbxUerMzMnSX2TgK2UgkrdC3PElPT7DUTF9QYO 35uw== X-Received: by 10.66.74.234 with SMTP id x10mr39997591pav.10.1361225790936; Mon, 18 Feb 2013 14:16:30 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Mon, 18 Feb 2013 15:15:50 -0700 Subject: Re: Python 3.3 vs. MSDOS Basic To: Python 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: 1361225801 news.xs4all.nl 6950 [2001:888:2000:d::a6]:37511 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39136 On Mon, Feb 18, 2013 at 3:01 PM, Chris Angelico wrote: > On Tue, Feb 19, 2013 at 8:54 AM, Ian Kelly wrote: >> Well, I don't see anything that looks especially slow in that code, >> but the algorithm that you're using is not very efficient. I rewrote >> it using dynamic programming (details left as an exercise), which got >> the runtime down to about 4 seconds. > > Did it involve a dictionary, mapping a value to its count, so that any > time you hit a value you've seen, you can short-cut it? That was my > first optimization consideration, though I didn't implement it in any > version, so as to keep the timings comparable. Ayup.