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


Groups > comp.lang.python > #95785

Re: Why Python is not both an interpreter and a compiler?

Path csiph.com!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <rosuav@gmail.com>
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; 'subject:Python': 0.05; 'compiler': 0.05; '(using': 0.07; 'executable': 0.07; 'interpreted': 0.07; 'pypy': 0.07; 'wrapper': 0.07; 'cc:addr :python-list': 0.09; 'subject:Why': 0.09; 'subject:both': 0.09; 'python': 0.10; 'language,': 0.11; 'programs.': 0.11; 'subject:not': 0.11; 'interpreter': 0.15; 'arbitrarily': 0.16; 'binary,': 0.16; 'compiler,': 0.16; 'etc...': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'reason?': 0.16; 'trivially': 0.16; 'wrote:': 0.16; 'basically': 0.18; 'python?': 0.18; '>>>': 0.20; '2015': 0.20; 'developer': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'machine': 0.21; '31,': 0.22; 'file.': 0.22; '(like': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; 'embed': 0.29; 'code:': 0.29; 'convert': 0.29; 'program,': 0.29; 'code': 0.30; 'becomes': 0.30; "can't": 0.32; 'core': 0.32; 'language.': 0.32; 'source': 0.33; 'file': 0.34; 'add': 0.34; 'received:google.com': 0.35; 'something': 0.35; 'but': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'difference': 0.38; 'why': 0.39; 'does': 0.39; 'unable': 0.39; 'hello,': 0.40; 'easy': 0.60; 'our': 0.64; 'virtually': 0.66; 'capabilities': 0.72; 'programs,': 0.72; 'chrisa': 0.84; 'to:none': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=9HRjBBMqZjIASgYj/W/XkHpPOXUgxi79qhNGuLd4OY0=; b=iYL1QGR4Xs+Cg2gqdMC0Iy0xd1jcbYt4qHC9Q9ma2nVJonPuSnV/1RFdkV7tUBTxnR J4dydcfBuodp8//cgjTeTUad4RLnXdJCZMT5XVW/9pe9LyQgmNU5qepDICmzFl1tE8KG UaMH0Ty4+DeoDmdUL1LpbHbtvGTaCku9hP4xdr7Ww5K3jmiLIMlm1irZckk5t2nfv1nL oycQIPVdpX0RyOL6wbgXmhARMC3wNQcuUmlfWEpmlpXOPyLUXcZjvZ1r89ZyYQvRDc9p nAqaXlTdGC7r90SPAVcyn5Iu+o4Qv5Vg2B7vVuo7g96UcZXs8dgL5oG+Iu0fW1uOaENT mWxQ==
MIME-Version 1.0
X-Received by 10.107.36.8 with SMTP id k8mr4064737iok.157.1441010979513; Mon, 31 Aug 2015 01:49:39 -0700 (PDT)
In-Reply-To <3e541d13-bc86-456c-8590-4ffd1af9cfd0@googlegroups.com>
References <3e541d13-bc86-456c-8590-4ffd1af9cfd0@googlegroups.com>
Date Mon, 31 Aug 2015 18:49:39 +1000
Subject Re: Why Python is not both an interpreter and a compiler?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11.1441010988.23514.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1441010988 news.xs4all.nl 23756 [2001:888:2000:d::a6]:47433
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 5142
X-Received-Body-CRC 2966650668
Xref csiph.com comp.lang.python:95785

Show key headers only | View raw


On Mon, Aug 31, 2015 at 6:35 PM, Mahan Marwat <mahanmarwat@gmail.com> wrote:
> What I know about an interpreter and a compiler is: they both convert source code to machine code and the only difference is, an interpreter convert it, line by line while compiler convert the whole source file.
> Now if we compile a C source file on C compiler, it will produce a small executable file. But if we compile (freeze) a Python source file on Python interpreter (using cx_freeze), it will produce a big executable file.
> Now the thing is C compiler does not embed a C compiler inside our program, while the Python interpreter (cx_freeze, pytoexe) embed Python interpreter inside our program, what is the reason?
> The question is, why cx_freeze etc... embed Python interpreter inside our programs, they are unable to produce machine code like C compiler do?
> Cant we program a language, which is both interpreted and compiled? The core developer cant add the compiling functionality to Python?

Compiling is trivially easy for trivial programs, and becomes
virtually impossible for arbitrarily complex and dynamic programs. In
an extreme example, Python includes the ability to execute arbitrary
code:

>>> exec("print('Hello, world!')")
Hello, world!

You basically can't compile that without having the full capabilities
of the Python language. If you want something that makes Python into
an executable binary, you either want a wrapper (like cx_freeze and
pytoexe and so on), or else something like the PyPy project. Check it
out - it's pretty cool!

ChrisA

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


Thread

Why Python is not both an interpreter and a compiler? Mahan Marwat <mahanmarwat@gmail.com> - 2015-08-31 01:35 -0700
  Re: Why Python is not both an interpreter and a compiler? Chris Angelico <rosuav@gmail.com> - 2015-08-31 18:49 +1000
  Re: Why Python is not both an interpreter and a compiler? Cameron Simpson <cs@zip.com.au> - 2015-08-31 19:59 +1000
  Re: Why Python is not both an interpreter and a compiler? Ben Finney <ben+python@benfinney.id.au> - 2015-08-31 21:41 +1000
    Re: Why Python is not both an interpreter and a compiler? Marko Rauhamaa <marko@pacujo.net> - 2015-08-31 16:39 +0300
      Re: Why Python is not both an interpreter and a compiler? Mahan Marwat <mahanmarwat@gmail.com> - 2015-08-31 10:48 -0700
        Re: Why Python is not both an interpreter and a compiler? Emile van Sebille <emile@fenx.com> - 2015-08-31 10:56 -0700
        Re: Why Python is not both an interpreter and a compiler? Ben Finney <ben+python@benfinney.id.au> - 2015-09-01 09:15 +1000
        Re: Why Python is not both an interpreter and a compiler? Luca Menegotto <otlucaDELETE@DELETEyahoo.it> - 2015-09-01 07:45 +0200
          Re: Why Python is not both an interpreter and a compiler? Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-01 11:21 -0600
        Re: Why Python is not both an interpreter and a compiler? Laura Creighton <lac@openend.se> - 2015-09-01 09:51 +0200
        Re: Why Python is not both an interpreter and a compiler? Steven D'Aprano <steve@pearwood.info> - 2015-09-02 01:20 +1000
          Re: Why Python is not both an interpreter and a compiler? Marko Rauhamaa <marko@pacujo.net> - 2015-09-01 19:20 +0300
            Re: Why Python is not both an interpreter and a compiler? Chris Angelico <rosuav@gmail.com> - 2015-09-02 03:06 +1000
            Re: Why Python is not both an interpreter and a compiler? Laura Creighton <lac@openend.se> - 2015-09-01 19:33 +0200
              Re: Why Python is not both an interpreter and a compiler? Marko Rauhamaa <marko@pacujo.net> - 2015-09-01 23:08 +0300
                Re: Why Python is not both an interpreter and a compiler? Chris Angelico <rosuav@gmail.com> - 2015-09-02 10:50 +1000
                Re: Why Python is not both an interpreter and a compiler? Laura Creighton <lac@openend.se> - 2015-09-02 09:09 +0200
                Re: Why Python is not both an interpreter and a compiler? wxjmfauth@gmail.com - 2015-09-02 01:25 -0700
            Re: Why Python is not both an interpreter and a compiler? Laura Creighton <lac@openend.se> - 2015-09-01 19:52 +0200
            Re: Why Python is not both an interpreter and a compiler? Steven D'Aprano <steve@pearwood.info> - 2015-09-02 12:49 +1000
              Re: Why Python is not both an interpreter and a compiler? Marko Rauhamaa <marko@pacujo.net> - 2015-09-02 06:58 +0300
              Re: Why Python is not both an interpreter and a compiler? Jussi Piitulainen <harvesting@makes.address.invalid> - 2015-09-02 08:59 +0300
  Re: Why Python is not both an interpreter and a compiler? Michael Torrie <torriem@gmail.com> - 2015-09-01 21:46 -0600

csiph-web