Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18758

Re: python philosophical question - strong vs duck typing

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 <python-python-list@m.gmane.org>
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 <lie.1296@gmail.com>
Subject Re: python philosophical question - strong vs duck typing
Date Wed, 11 Jan 2012 00:05:36 +1100
References <CAOFf2a0dG1tR1-2sJnqCCGqVXocqvzGScGeDJXeXwKdfdvuT-Q@mail.gmail.com> <mailman.4383.1325623116.27778.python-list@python.org> <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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4593.1326200757.27778.python-list@python.org> (permalink)
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

Show key headers only | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: python philosophical question - strong vs duck typing Terry Reedy <tjreedy@udel.edu> - 2012-01-03 15:38 -0500
  Re: python philosophical question - strong vs duck typing Ben Finney <ben+python@benfinney.id.au> - 2012-01-04 10:10 +1100
  Re: python philosophical question - strong vs duck typing alex23 <wuwei23@gmail.com> - 2012-01-03 18:15 -0800
    Re: python philosophical question - strong vs duck typing John Nagle <nagle@animats.com> - 2012-01-08 21:35 -0800
      Re: python philosophical question - strong vs duck typing Robert Kern <robert.kern@gmail.com> - 2012-01-09 10:45 +0000
        Re: python philosophical question - strong vs duck typing John Nagle <nagle@animats.com> - 2012-01-13 09:30 -0800
      Re: python philosophical question - strong vs duck typing Lie Ryan <lie.1296@gmail.com> - 2012-01-11 00:05 +1100

csiph-web