Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1a.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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'algorithm': 0.04; 'from:addr:yahoo.co.uk': 0.04; 'mentioned,': 0.07; '128': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'language.': 0.14; '"in': 0.16; 'cases:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'slight': 0.16; 'solver': 0.16; 'strategy:': 0.16; 'worst': 0.16; 'modification': 0.16; 'language': 0.16; 'wrote:': 0.18; 'result.': 0.19; 'example': 0.22; 'header:User-Agent:1': 0.23; 'replace': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'change,': 0.30; "i'm": 0.30; '(on': 0.31; 'dropped': 0.31; 'purely': 0.31; 'run': 0.32; 'running': 0.33; 'something': 0.35; 'but': 0.35; 'fun,': 0.36; "i'll": 0.36; 'should': 0.36; 'seconds': 0.37; 'two': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'solve': 0.60; "you're": 0.61; 'first': 0.61; 'save': 0.62; 'times': 0.62; 'our': 0.64; 'more': 0.64; 'different': 0.65; '(that': 0.65; 'charset:windows-1252': 0.65; 'believe': 0.68; 'eight': 0.74; '5.9': 0.84; '884': 0.84; 'benchmark': 0.84; 'dramatically': 0.84; 'gut': 0.84; 'right).': 0.84; 'careful': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Sudoku solver Date: Sun, 29 Mar 2015 19:26:26 +0100 References: <87r3sdnw5t.fsf@elektro.pacujo.net> <4e81bdb9-52db-46e6-b449-d4241cb2a3f2@googlegroups.com> <87twx8amww.fsf@elektro.pacujo.net> <82e7c5b9-2f0f-405b-859c-b74916c475e0@googlegroups.com> <55176c2c$0$13009$c3e8da3$5496439d@news.astraweb.com> <87619j7kbu.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-78-147-178-243.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 In-Reply-To: <87619j7kbu.fsf@elektro.pacujo.net> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 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: 48 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1427653605 news.xs4all.nl 2821 [2001:888:2000:d::a6]:38345 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88274 On 29/03/2015 19:03, Marko Rauhamaa wrote: > BartC : > >> As Chris mentioned, when I say 'faster than C', I mean X running my >> algorithm was faster then C running Marko's algoritim (on Ian's data). >> This was just an illustration of algorithm being more important than >> language. > > Be careful with the benchmark comparisons. Ian's example can be solved > with the identical algorithm in eight different ways (four corners, left > or right). I ran the example with my recent Python solver and got these > times in the eight cases: > > 884 s > 2.5 s > 13 s > 499 s > 5.9 s > 128 s > 1360 s > 36 s > > (That suggests a slight modification to the original strategy: solve it > in each of the eight ways "in parallel" and the worst case should be > significantly alleviated.) > > I'm actually fascinated by the Python modifications that were > conceptually insignificant but dramatically speeded up the execution > (7880 seconds to 884 seconds). That's something I'll have to keep in > mind in the future. > > > Marko > One thing I have come to rely on over the years is never, ever trust your gut instincts about Python performance, you're almost inevitably wrong. When I first came across the Norvig solver I made a change, purely for fun, to replace two calls to len() with a single call and save the result. The run time to solve each puzzle dropped by around 5%. I believe this meets your "conceptually insignificant". -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence