Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'run-time': 0.05; 'compile- time': 0.07; 'compiler': 0.07; 'differently.': 0.07; 'pypy': 0.07; 'integers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:python': 0.10; 'binary': 0.13; 'float': 0.13; 'case.': 0.15; 'binaries': 0.16; 'compiler,': 0.16; "function's": 0.16; 'shed': 0.16; 'subject:question': 0.17; 'wrote:': 0.18; 'arguments': 0.18; 'once,': 0.18; 'header:In-Reply-To:1': 0.22; 'levels.': 0.23; 'similar,': 0.23; 'code': 0.25; 'guess': 0.26; 'function': 0.27; 'compile': 0.29; 'pm,': 0.29; 'array': 0.30; 'seem': 0.30; 'does': 0.32; 'determined': 0.32; 'header:User- Agent:1': 0.33; 'actually': 0.33; 'header:X-Complaints-To:1': 0.33; 'to:addr:python-list': 0.34; 'it.': 0.34; 'certain': 0.34; 'be,': 0.34; 'integer': 0.34; 'mix': 0.34; 'smart': 0.34; 'something': 0.35; 'received:au': 0.36; 'example,': 0.37; 'subject:skip:p 10': 0.37; 'but': 0.37; 'run': 0.37; 'enough': 0.38; 'received:org': 0.38; 'prepared': 0.39; 'being': 0.39; 'to:addr:python.org': 0.40; 'might': 0.40; 'type': 0.61; 'john': 0.62; 'back': 0.62; 'ever': 0.65; 'alternative': 0.65; 'floats.': 0.84; 'slow.': 0.84; 'received:110': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Lie Ryan Subject: Re: python philosophical question - strong vs duck typing Date: Wed, 11 Jan 2012 00:05:36 +1100 References: <59305aab-7ddf-4c61-b8ba-025a2ce10b48@d10g2000vbh.googlegroups.com> <4f0a7ca9$0$1727$742ec2ed@news.sonic.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 110-175-240-90.static.tpgi.com.au User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111124 Thunderbird/8.0 In-Reply-To: <4f0a7ca9$0$1727$742ec2ed@news.sonic.net> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326200757 news.xs4all.nl 6847 [2001:888:2000:d::a6]:57870 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18758 On 01/09/2012 04:35 PM, John Nagle wrote: > A type-inferring compiler has to analyze the whole program at > once, because the type of a function's arguments is determined > by its callers. This is slow. The alternative is to guess > what the type of something is likely to be, compile code at > run time, and be prepared to back out a bad guess. This > requires a very complex system, but that's how PyPy does it. > Performance does not seem to reach Shed Skin levels. With a smart enough compiler, JIT compiler can actually be faster than compile-time optimizations; the reason being that different people might use the same code differently. For example, say we have a function that takes an array of numbers which can be integer or float or a mix of integers and floats. A compile-time optimizer cannot optimize this function safely; but a run-time optimizer might notice that a certain user only ever use the function with an array of integers and generate an optimized code for that particular case. Profile-guided optimizations (PGO) can do something similar, but then it means a single program will have to have twenty different binaries for twenty different use cases; or a very large binary that contains code optimized for every possible thing.