interpreter vs. compiled

castironpi castironpi at gmail.com
Tue Jul 29 06:21:31 CEST 2008


On Jul 28, 5:58 pm, Fuzzyman <fuzzy... at gmail.com> wrote:
> On Jul 27, 6:02 am, castironpi <castiro... at gmail.com> wrote:
>
>
>
> > On Jul 24, 11:04 pm, Tim Roberts <t... at probo.com> wrote:
>
> > > castironpi <castiro... at gmail.com> wrote:
>
> > > >Compiling a program is different than running it.  A JIT compiler is a
> > > >kind of compiler and it makes a compilation step.  I am saying that
> > > >Python is not a compiler and in order to implement JIT, it would have
> > > >to change that fact.
>
> > > And I'm saying you are wrong.  There is NOTHING inherent in Python that
> > > dictates that it be either compiled or interpreted.  That is simply an
> > > implementation decision.  The CPython implementation happens to interpret.
> > > The IronPython implementation compiles the intermediate language to native
> > > machine language.
>
> > > >> of Python that uses .NET.  In that case, the code *IS* JIT compiled to
> > > >> assembly when the program starts.
>
> > > >But still not the user's code, only the interpreter, which is running
> > > >in assembly already anyway in CPython.
>
> > > In CPython, yes.  In IronPython, no; the user's code is compiled into
> > > machine language.  Both of them are "Python".
> > > --
> > > Tim Roberts, t... at probo.com
> > > Providenza & Boekelheide, Inc.
>
> > In CPython yes.  In IronPython yes:  the parts that are compiled into
> > machine code are the interpreter, *not user's code*.  Without that
> > step, the interpreter would be running on an interpreter, but that
> > doesn't get the user's statement 'a= b+ 1' into registers-- it gets
> > 'push, push, add, pop' into registers.
>
> Well - in IronPython user code gets compiled to in memory assemblies
> which can be JIT'ed.
>
> Michael Foord
> --http://www.ironpythoninaction.com/

I don't believe so.

Take a sample interpreted language, to be compiled by a sample JIT.

a= stack( )
a.push( 0 )
a.push( 2 )
a.push( 4 )

Bytecode output is:

allocate var0
call STACK_CONSTRUCTOR
initialize var0 return
call METH0 var0 const 0
call METH0 var0 const 2
call METH0 var0 const 4

JIT output is assembly:

reg0 malloc 4
setjmp
jmp STACK_CONSTRUCTOR
popjmpv reg1
setjmp
reg1 0
jmp METH0
reg1 2
jmp METH0
reg1 4
jmp METH0

But when you compare the C code for 'x= y+ 1' to Python JIT code for
'x= y+ 1', there is no stack and no error checking.  They're quite
different.  In a JIT language, Python runs in native assembly, output
similar to CPython, theoretically.  User's code -does- -not- -run-.
It is moved in to and out of a stack by a program that is running,
namely the interpreter, whether it came from C and a compiler,
or .NEt, bytecode, and a JIT.



More information about the Python-list mailing list