Python Tutorial - Python Tutorials - Introduction & Architecture DevSkrol
Python Tutorial - Python Tutorials - Introduction & Architecture DevSkrol
Previous
Next
In this section of this tutorial, we will learn about Python History, It’s Architecture and it’s
properties.
Python is mainly designed with the concept of code readability and ease of use.
History:
Python was created in December 1989 by Guido van Rossum.
Guido van Rossum was working on an OS development project named Amoeba. This OS
was intended to make a network of computers as a single computer using a distributed
kernel.
They had to write utility programs for this OS in C. But it was very time taking process.
At that time programmers were tired of writing C programs or Unix shell programs.
Guido van Rossum started a hobby project of creating a new programming language at
December holidays of 1989. He named that project as Python inspired from a TV show
“Monty Python’s Flying Circus”.
After 3 months of his work, even though Python was not yet fully grown to use in place of
C, the language was very liked by the programmers in his office. Also, they started using
Python as it was fun and increased the productivity.
Python 2.0 was released on 2000 and Python 3 was released in 2008 with major changes in
the language.
Python 3 is not completely backward-compatible. Even the print statement’s syntax was
changed.
Python Architecture:
Python is an Interpreted Language where interpretation is different from compilation.
For this, we need to convert our human readable source code to machine readable machine
code.
Machine code is a binary representation of the computer program which can be
directly run by the computer.
If you are having a book written in other languages than your native language, then a
translator translates that book to your native language.
Other language book -> human translator -> Native language book
Languages C, C++ are compiled and compiler converts the source code to machine code
which is a binary representation.
So the problem of converting the high level language to low level is solved right?
For exam, the language C converts the source code to machine code. But the machine code
is dependent on the platform in which it is created.
i.e., For each platform the machine code differs. The machine code of 2 different OS will not
be same.
So we cannot run the windows compiled C program (i.e., the machine code) on Linux.
In order to run your same C program in Linux, you will need a Linux machine and compile
the program in it. This will generate a machine code for Linux and then you can run it in a
Linux machine.
Basically C provide a level of flexibility for platform independent. But it is not fully
independent.
Due to this we a common intermediate code that can run on any platform without compile
it again.
Byte code is an intermediate code for which we need a separate processor like virtual
machine (ex. JVM).
Initially, the program will be compiled as usual but it generates a common byte code. This
is not same as machine code . However at this stage we have completed the compilation
process. The code will not be human readable.
Then what is this for, neither machine nor human can read.
The main problem in C compiler is it can generate machine code only for its platform.
So we need a separate processor which will be installed/enabled in OS. This processor will
take care of executing the byte code and convert it to the OS dependent machine code in
which it is installed. Then this machine code will run in the OS.
What is compilation?
In Code compilation, the source code is first converted into a machine code/byte code
which is a low-level code understandable only by machines.
In this compilation state the errors will be escalated and the compilation will be aborted if
any. If no errors compilation completed successfully and byte code or machine code is
created. This machine code will be run by the machines.
Each instruction will be validated by syntax checker and some other translations for
data types will be done at first level. Then the result will be compiled to byte code or
machine code. And then a virtual machine will be used to run in case of byte code.
It is parsed through the syntax checker and translator and then its compiler converts the
source code to byte code and finally Python Virtual Machine (PVM) will convert the byte
code to machine code.
Figure 2: Python Architecture; Image by Author
Figure 1: Python Advantages; Image by Author
Advantages of Python:
⭕️ Python gives programmer a freedom to use the variables without mentioning the
Datatype. The translator inside the python interpreter will convert it to appropriate
datatype. This process is called Dynamic Typic.
But due to this there is an extra step in compilation process which makes python slower
than statically typed languages.
⭕️ As Python has a virtual machine, it will convert the byte code to the corresponding
machine code
at runtime.
The compiled
Python code
can run in
any platform.So, it is
Platform Independent.
It has so many Libraries, you can call it as a chunk of code or collection of modules, which
can be downloaded, installed whenever it is needed.
For example, if we need to work on web scrapping then we can use the library
“BeautifulSoup”. This library parses the HTML documents gracefully and it is easy to use
than implementing our own loops and string manipulations to search the HTML elements.
Yes! Python has class and object concept so that it can used in bigger projects and it will
provide a clear structure to the project. There are various IDEs which can be used. Example:
PyCharm from JetBrains community.
As it is procedural/Functional, we can use Python for experimental purpose. In that case you
do not need to bother about the file structure, classes and objects and other project related
components.
Write a line of code. In command prompt, just an enter does the magic.
It is an Interactive Language: As it answers immediately for each step, you can interact
with the python interpreter directly.
⭕️ Easy to Learn: One more important and interesting thing about Python is its simple
Syntax.
⭕️ While working on Python, you can get a lot of community support from internet as it’s
been there for long enough and so many people are using it. Example: Stackoverflow.
So, that’s all about Python and now we will move on to the real coding part.
DevSkrol 0
Python Short Quiz #2 – Architecture
Quiz on Python Introduction & Architecture. Difficulty Level is Easy. Concept: Python
Architecture
DevSkrol 0
Previous
Next
ARTICLES: 86
Related Posts
Leave a Reply
Your email address will not be published. Required fields are marked *
Save my name, email, and website in this browser for the next time I comment.
Post Comment