Python vs. Lisp -- please explain

Steven D'Aprano steve at REMOVEMEcyber.com.au
Tue Feb 21 03:43:46 EST 2006


Donn Cave wrote:

> Quoth Steven D'Aprano <steve at REMOVETHIScyber.com.au>:
> ...
> | Nobody denies that Python code running with no optimization tricks is
> | (currently) slower than compiled C code. That's a matter of objective
> | fact. Nobody denies that Python can be easily run in interactive mode.
> | Nobody denies that *at some level* Python code has to be interpreted.
> |
> | But ALL code is interpreted at some level or another. And it is equally
> | true that at another level Python code is compiled. Why should one take
> | precedence over the other?
> 
> I have no idea, what precedence?  

There seem to be two positions in this argument:

The "Python is interpreted and not compiled" camp, who 
appear to my eyes to dismiss Python's compilation stage 
as a meaningless technicality.

The "Python is both interpreted and compiled" camp, who 
believe that both steps are equally important, and to 
raise one over the other in importance is misleading.


 > All I'm saying is that Python matches
> what people think of as an interpreted language.

Most people in IT I know of still think of 
"interpreted" as meaning that every line of source code 
is parsed repeatedly every time the code is executed. 
Even when they intellectually know this isn't the case, 
old habits die hard -- they still think of 
"interpreted" as second class.

If you think that Python has to parse the line "print 
x" one hundred times in "for i in range(100): print x" 
then you are deeply, deeply mistaken.

That's why Sun doesn't describe Java as interpreted, 
but as byte-code compiled. They did that before they 
had JIT compilers to compile to machine code. 
Consequently nobody thinks of Java source having to be 
parsed, and parsed, and parsed, and parsed again.


 > You can deny it, but
> but it's going to look like you're playing games with words, and to no
> real end, since no one could possibly be deceived for very long.

Pot, meet kettle.

A simple question for you: does Python compile your 
source code before executing it? If you need a hint, 
perhaps you should reflect on what the "c" stands for 
in .pyc files.


 > If you
> give me a Python program, you have 3 choices:  cross your fingers and
> hope that I have the required Python interpreter version, slip in a
> 25Mb Python interpreter install and hope I won't notice, or come clean
> and tell me that your program needs an interpreter and I should check to
> see that I have it.

Hey Donn, here is a compiled program for the PowerPC, 
or an ARM processor, or one of IBM's Big Iron 
mainframes. Or even a Commodore 64. What do you think 
the chances are that you can execute it on your 
x86-compatible PC? It's compiled, it should just 
work!!! Right?

No of course not. If your CPU can't interpret the 
machine code correctly, the fact that the code is 
compiled makes NO difference at all.

In other words, I have three choices:

- cross my fingers and hope that you have the required 
interpreter (CPU);

- slip in an interpreter install (perhaps an emulator) 
and hope you won't notice;

- or come clean and tell you that my program needs an 
interpreter ("Hey Donn, do you have a Mac you can run 
this on?") and you should check to see that you have it.



-- 
Steven.




More information about the Python-list mailing list