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


Groups > comp.lang.python > #40488

Re: Why is it impossible to create a compiler than can compile Python to machinecode like C?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!eweka.nl!hq-usenetpeers.eweka.nl!xlned.com!feeder1.xlned.com!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; 'python,': 0.02; 'else:': 0.03; 'interpreter': 0.04; 'subject:Python': 0.05; 'compiler': 0.05; 'that?': 0.05; "'a'": 0.07; 'line:': 0.07; 'pypy': 0.07; 'referring': 0.07; 'rewrite': 0.07; 'statically': 0.07; 'type,': 0.07; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'runtime': 0.09; 'subject:Why': 0.09; 'subject:create': 0.09; 'terry': 0.09; 'typed': 0.09; 'def': 0.10; 'language,': 0.11; "'b'": 0.16; 'b):': 0.16; 'better?': 0.16; 'binding,': 0.16; 'compilers': 0.16; 'executed,': 0.16; 'objects?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject: \n ': 0.16; 'variations': 0.16; 'later': 0.16; 'string': 0.17; 'wrote:': 0.17; 'integer': 0.17; 'module,': 0.17; 'string,': 0.17; 'jan': 0.18; 'input': 0.18; 'latter': 0.22; 'needed.': 0.23; 'statement': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'object,': 0.27; 'strongly': 0.27; 'header:X-Complaints-To:1': 0.28; 'subject:like': 0.29; 'types.': 0.29; 'objects': 0.29; 'that.': 0.30; 'function': 0.30; 'figure': 0.30; 'could': 0.32; 'function.': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; "can't": 0.34; 'program,': 0.34; 'pm,': 0.35; 'subject:?': 0.35; 'something': 0.35; 'received:org': 0.36; 'skip:{ 10': 0.36; 'does': 0.37; 'two': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'different': 0.63; 'ever': 0.63; 'therefore': 0.65; 'believe': 0.69; 'believe,': 0.84; 'dict,': 0.84; 'fly,': 0.84; 'received:fios.verizon.net': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: Why is it impossible to create a compiler than can compile Python to machinecode like C?
Date Mon, 04 Mar 2013 19:31:09 -0500
References <b428fdef-a577-45c0-b37c-60bde74e3ae1@googlegroups.com> <kh2iij$msn$1@reader1.panix.com> <b91a25e1-0d00-4b29-a229-47ad32d9feae@h17g2000yqe.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-173-75-251-66.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3
In-Reply-To <b91a25e1-0d00-4b29-a229-47ad32d9feae@h17g2000yqe.googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.2857.1362443484.2939.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362443484 news.xs4all.nl 6980 [2001:888:2000:d::a6]:33447
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40488

Show key headers only | View raw


On 3/4/2013 5:55 PM, CM wrote:

> Could you help me understand this better?  For example, if you
> have this line in the Python program:
>
> foo = 'some text'
> bar = {'apple':'fruit'}
>
> If the interpreter can determine at runtime that foo is a string
> and bar is a dict, why can't the compiler figure that out at
> compile time?  Or is the problem that if later in the program
> you have this line:
>
> foo = 12
>
> now foo is referring to an integer object, not a string, and
> compilers can't have two names referring to two different
> types of objects?

I believe you mean one name referring to multiple types.

> Something like that?

Something like that. In python, objects are strongly typed, names do not 
have types. Or if you prefer, names are typed according to their current 
binding, which can freely change. As for why this can be an advantage, 
consider this simple function.

def min2(a, b):
   if a <= b:
     return a
   else:
     return b

When the def statement is executed, the names 'a' and 'b' have no 
binding and therefore no type, not even a temporary type.

In a statically typed language, either you or the compiler must rewrite 
that function for every pair of types that are ever input to min2. If 
the compiler does it, it either has to analyze an entire program, or it 
have to compile variations on the fly, as needed. The latter is what the 
psycho module, and, I believe, the pypy jit compiler does.

-- 
Terry Jan Reedy

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


Thread

Why is it impossible to create a compiler than can compile Python to machinecode like C? kramer65 <kramerh@gmail.com> - 2013-02-28 12:25 -0800
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Matty Sarro <msarro@gmail.com> - 2013-02-28 15:50 -0500
    Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-01 02:55 +0000
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Stefan Behnel <stefan_ml@behnel.de> - 2013-02-28 22:03 +0100
    Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-01 03:47 +0000
      Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? alex23 <wuwei23@gmail.com> - 2013-02-28 20:31 -0800
      Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Stefan Behnel <stefan_ml@behnel.de> - 2013-03-01 08:48 +0100
        Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-02 01:49 +0000
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Chris Angelico <rosuav@gmail.com> - 2013-03-01 08:10 +1100
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Stefan Behnel <stefan_ml@behnel.de> - 2013-02-28 22:17 +0100
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Dave Angel <davea@davea.name> - 2013-02-28 16:18 -0500
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Modulok <modulok@gmail.com> - 2013-02-28 14:19 -0700
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Jonas Geiregat <jonas@geiregat.org> - 2013-02-28 22:33 +0100
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Nobody <nobody@nowhere.com> - 2013-02-28 22:01 +0000
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Terry Reedy <tjreedy@udel.edu> - 2013-02-28 17:06 -0500
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-28 21:09 -0500
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-01 04:27 +0000
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? alex23 <wuwei23@gmail.com> - 2013-02-28 20:38 -0800
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? 88888 Dihedral <dihedral88888@googlemail.com> - 2013-02-28 22:21 -0800
  Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Grant Edwards <invalid@invalid.invalid> - 2013-03-04 16:36 +0000
    Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? CM <cmpython@gmail.com> - 2013-03-04 14:55 -0800
      Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? 88888 Dihedral <dihedral88888@googlemail.com> - 2013-03-04 15:12 -0800
      Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Terry Reedy <tjreedy@udel.edu> - 2013-03-04 19:31 -0500
      Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Chris Angelico <rosuav@gmail.com> - 2013-03-05 11:33 +1100
      Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Benjamin Kaplan <benjamin.kaplan@case.edu> - 2013-03-04 16:27 -0800
    Re: Why is it impossible to create a compiler than can compile Python to machinecode like C? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-05 01:35 +0000

csiph-web