Chris Fuller wrote:
On Monday 06 December 2010, Jaidev Deshpande wrote:

Also, wikipedia says Python is an interpreted language, what does that
mean?

The "interpreted" bit refers to the fact that the source code is not compiled before it is run. This is also true of Matlab.

That's not completely correct. What do you think the compile() function in Python does, or what the "c" in .pyc files stands for?

Strictly speaking, languages are neither interpreted or compiled, they just *are*. Implementations of languages are either interpreted or compiled.

In Python's case, the three major implementations (CPython, Jython and IronPython) take the source code and compile it to byte-code rather than native machine code. Then the byte-code is executed by a virtual machine, rather than machine code executed directly by your CPU.

This use of a virtual machine is much the same as what (e.g.) Java does. However, Java many years ago developed the ability to compile direct to native machine code, which is much faster to run. That step is considerably harder for Python. However, there is good progress in that direction:

* Psyco is an old but still serviceable Just In Time compiler for 32-bit versions of CPython which can speed many (but not all) operations up greatly, by compiling them to native machine code at runtime.

* Berp and HoPe are experimental implementations of Python written in Haskell instead of C. Berp translates the Python source code into Haskell, which can then be compiled to machine code. I'm not sure about HoPe.

* UnPython is an experimental attempt to translate Python into C, which can then be compiled to machine code.

* PyPy is an optimizing Python virtual machine written in Python itself, using JIT technology to produce faster code. PyPy now is about twice as fast as CPython, for typical programs, and the ambitious aim is to become an general-purpose optimizing engine that can produce code that runs faster than the equivalent written in C.



--
Steven


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to