Python is a brilliant and simple to use language.

Here's how it works under the hood๐Ÿ‘‡
( It is truly fascinating, trust me! )
First of all, ๐˜ธ๐˜ฉ๐˜ข๐˜ต ๐˜ช๐˜ด ๐˜—๐˜บ๐˜ต๐˜ฉ๐˜ฐ๐˜ฏ?

Python is an high-level, (mostly) interpreted programming language which is dynamically typed made by @gvanrossum ,released in 1991 as a hobby project.
What the hell does that mean?

Let's break it down. ๐Ÿ‘‡
> Python is a ๐—ต๐—ถ๐—ด๐—ต ๐—น๐—ฒ๐˜ƒ๐—ฒ๐—น language.

A high level language is a language that simplifies programming for us humans.

On the left we have assembly (low-level) and Python on the right(high level)

Both output Hello World, but Python looks a hell lot less complex!
In order to make python this easy to read and write, a trade off which we had to make was that it would run slower than a lower level language like assembly.

(for example the assembly code on the right might run in 0.0001 s, while the python code might run in about 0.5 s)
> Python is an (mostly) ๐—ถ๐—ป๐˜๐—ฒ๐—ฟ๐—ฝ๐—ฟ๐—ฒ๐˜๐—ฒ๐—ฑ ๐—น๐—ฎ๐—ป๐—ด๐˜‚๐—ฎ๐—ด๐—ฒ.

Python code (your .py file) is compiled( only step of compilation) to bytecode in a .pyc/.pyo file. This bytecode file contains instructions which is executed by your python interpreter ๐Ÿ‘‡
(the .exe file you installed on your computer to get python, it is installed on MacOS and linux by default)

These bytecode instructions are executed on a Virtual Machine and not on the CPU (the processor of your computer) directly.
A language like C++ is quite the opposite of python, C++ code is compiled to machine code and then run on a CPU.
> Python is a ๐—ฑ๐˜†๐—ป๐—ฎ๐—บ๐—ถ๐—ฐ ๐—น๐—ฎ๐—ป๐—ด๐˜‚๐—ฎ๐—ด๐—ฒ.

This means that the types of variables do not have to be declared like C++. This is because Python's nature of being interpreted. The interpreter does all the hard work of validating the variable's type.
And that is a basic explanation on how Python works! ๐Ÿ˜€
You can follow @PrasoonPratham.
Tip: mention @twtextapp on a Twitter thread with the keyword โ€œunrollโ€ to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.