Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!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.033 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'lines,': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '(about': 0.16; 'interest,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'thanks,': 0.17; 'slightly': 0.19; 'header:User-Agent:1': 0.23; 'looks': 0.24; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'too.': 0.31; 'faster,': 0.31; 'but': 0.35; 'there': 0.35; 'skip:\xd0 10': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'matter': 0.61; 'total': 0.65; 'received:46': 0.66; 'worth': 0.66; '8bit%:94': 0.72; '10%': 0.74; '8bit%:43': 0.74; 'measurable': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Serhiy Storchaka Subject: Re: Challenge: optimizing isqrt Date: Tue, 25 Nov 2014 21:31:43 +0200 References: <54543787$0$13005$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 46.211.144.47 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.0 In-Reply-To: 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416944005 news.xs4all.nl 2904 [2001:888:2000:d::a6]:53222 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81525 п'ятниця, 21-лис-2014 08:15:57 ви написали: > This looks very good indeed. As a matter of interest, is there any > particular reason you have used 2*b instead of b+b? Might b+b be faster > than b*2? Yes, it is slightly faster, but the effect is indiscernible in total time. But there is not harm to use b+b. > Also, in various lines, you use //2. Would >>1 be quicker? On reflection, > perhaps you have had to use //2 because >>1 cannot be used in those > situations. I thought this effect would be insignificant too. But actually it is measurable (about 10% for some input). Thanks, this optimization is worth to be applied.