Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'algorithm': 0.03; 'subject:Python': 0.05; 'python': 0.09; 'coding,': 0.09; 'runtime': 0.09; '107': 0.16; 'basic.': 0.16; 'seconds.': 0.16; 'subject:3.3': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'pace': 0.17; 'code,': 0.18; 'app': 0.19; 'feb': 0.19; 'equivalent': 0.20; 'bit': 0.21; 'runs': 0.22; 'programming': 0.23; 'header:In-Reply-To:1': 0.25; 'looks': 0.26; 'message- id:@mail.gmail.com': 0.27; 'run': 0.28; 'coded': 0.29; 'surprised': 0.29; 'usually': 0.30; 'basic': 0.30; 'problem': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'project': 0.34; 'compared': 0.35; 'especially': 0.35; 'pm,': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'really': 0.36; 'but': 0.36; 'anything': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'john': 0.60; 'subject:. ': 0.66; '1980s': 0.84; '2013': 0.84; 'sec.': 0.84; 'subject:Basic': 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:content-transfer-encoding; bh=5kmwACuF6zGY0PrI/ECy1oLuavdz+DP6+a13aTbZTJY=; b=DjzkDiqKj5PBQNNjyEfmaXAKrRHd+WVDOjaCQhfC+KMJrt7jS5OQi0ULT+a0VVu7vz r8viEWE66hMcAigsQ6kgft+Wbg5mCfcnCIOQu1uA7BqPBqAHQvpJr1y2kKUmkQzmI4wd 1LCteynPVeFyKzLYPEGsCmAesV+qIPiGoEKTg2Tl1blfBjBRE3uOln7B13KsTtiFL/Pe 7fAFsEq2pYIwsy+mFmRXg+nLH53sIHDprxmSTl04qfoHu+rIGfReIz60f4zsDWS/0Jl2 eAzMiwejeyf5lU7x02jlqaok5aMkVCtl6/7SSNDHvOipflIVCQnfVLfTMPi4KPZI1yRR 3rwQ== X-Received: by 10.68.129.9 with SMTP id ns9mr34535541pbb.16.1361224505598; Mon, 18 Feb 2013 13:55:05 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Mon, 18 Feb 2013 14:54:24 -0700 Subject: Re: Python 3.3 vs. MSDOS Basic To: Python Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 1361224508 news.xs4all.nl 6898 [2001:888:2000:d::a6]:49771 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39132 On Mon, Feb 18, 2013 at 12:13 PM, John Immarino wrote: > I coded a Python solution for Problem #14 on the Project Euler website. I= was very surprised to find that it took 107 sec. to run even though it's a= pretty simple program. I also coded an equivalent solution for the proble= m in the old MSDOS basic. (That's the 16 bit app of 1980s vintage.) It ran= in 56 sec. Is there a flaw in my coding, or is Python really this slow in = this particular application. MSDOS Basic usually runs at a snails pace comp= ared to Python. 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.