Python, Java and C run time.

C

  • gcc compiles your c code and generates an executable code. This code has machine instructions, means CPU can understand these instructions. Kernel has to load the executable code into memory and point CPU to starting instruction.

Java

  • java converts the java code into byte code and this byte code is executed on JVM (written in C).
  • JVM understands byte code and perform actions based on byte code instructions.

Python

  • Python compiles your code and generates a byte code.  This is not a machine code, it is python representation. This byte code is executed on Python virtual machine (PVM). PVM is the run time environment of python, it is installed as part of your python installation. This process is hidden to users who are executing .py file with python binary. Python also generates .pyc (compiled python) files  We can ship the .pyc files as your product. It might be easy to decode the python source from pyc.  python can not be used to delivery a proprietary product where they don’t want to expose alogs or logics involved.  There is a concept of frozen binaries, which packages .pyc, PVM and some support files and provide a .exe file. This is how python applications are shipped. You no need to install Python on your machine.
  • To just compile python code and create .pyc files,
python -m py_compile script.py
  • Since object code is not a machine code, Byte code instruction execution takes more time because they are not executed directly on CPU. PVM needs to understand these byte code instructions and take action.
  • There is Jpython, which converts your python program to Java byte code and run these java byte code on JVM.

Reference:

How Python Runs Programs

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s