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


Groups > comp.lang.python > #40486

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

Newsgroups comp.lang.python
Date 2013-03-04 15:12 -0800
References <b428fdef-a577-45c0-b37c-60bde74e3ae1@googlegroups.com> <kh2iij$msn$1@reader1.panix.com> <b91a25e1-0d00-4b29-a229-47ad32d9feae@h17g2000yqe.googlegroups.com>
Message-ID <3447eb2a-892e-44cd-8136-2cda4d7165f5@googlegroups.com> (permalink)
Subject Re: Why is it impossible to create a compiler than can compile Python to machinecode like C?
From 88888 Dihedral <dihedral88888@googlemail.com>

Show all headers | View raw


On Tuesday, March 5, 2013 6:55:06 AM UTC+8, CM wrote:
> > The main issue is that python has dynamic typing.  The type of object
> 
> > that is referenced by a particular name can vary, and there's no way
> 
> > (in general) to know at compile time what the type of object "foo" is.
> 
> >
> 
> > That makes generating object code to manipulate "foo" very difficult.
> 
> 
> 
> 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?  Something like that?
> 
> 
> 
> I in no way doubt you that this is not possible, I just don't
> 
> understand enough about how compiling works to yet "get"
> 
> why dynamic typing is a problem for compilers.
> 
> 
> 
> Thanks.

The dynamic type part is normally in the higher level components of 
objects and functions and generators.

Of course if one can be sure of the types of variables used 
in some functions then that is the cython way to speed up pure OOP python
programs in executions.


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