How does python bytecode works?

Terry Reedy tjreedy at udel.edu
Sun Jun 17 14:10:32 EDT 2012


On 6/17/2012 5:54 AM, gmspro wrote:
> We know python is written in C.

Nope. The CPython Python interpreter is written in (as portable as 
possible) C. The Jython, IronPython, and PyPy Python interpreters are 
written in Jave, C#, and Python respectively. Each compiles Python to 
something different. I presume each (normally) saves the compiled form 
until the source changes. CPython compiles to CPython-specific bytecode. 
It saves the bytecode as a .pyc file in a .__cache__ subdirectory (in 3.2+).

> C is not portable.

Yes it is (mostly). CPython has been compilied, with minor adjustments, 
on numerous (>20) systems.

> So how does python work on a webserver like apache/httpd for a python
> website?

The website has a Python interpreter.

> How does the intermediate language communicate with server without
> compiling python code?

The Python interpreter of the website *does* compile Python code to 
whatever it compiles to.

-- 
Terry Jan Reedy






More information about the Python-list mailing list