Python Key Characteristics and How Your Code Runs
Last updated on
Introduction
Before starting to write any Python code, it’s useful to understand what makes a language different from others, and what happens under the hood when you actually execute your code.
In this article we will look at Python’s key characteristics which are: interpreted, dynamically typed, garbage collected, multi-paradigm, and batteries-included. And we will explain what’s exactly happening when you run python3 hello.py under the hood.
If that sounds interesting, let’s dive in.
What is Python
Python is a general purpose, interpreted programming language created by Guido Van Rossum in 1991.

It can run in any operating system, and it’s one of the most popular programming languages, mainly used for for machine learning, data science, automations, web backends, AI…
Key Characteristics
When thinking about Python in general you have to have this mental image in mind.

Python has 5 main characteristics that distinguish it
-
Interpreted: Code runs line-by-line through the Python interpreter, no compilation step is needed before running the program.
-
Dynamically typed: Since no compilation step is happening, variable types are resolved at runtime dynamically, so there is no need to declare them upfront, in contrast with other statically typed languages like C, C++ or Golang.
-
Garbage Collected: Python’s garbage collector manages the memory automatically for you, for example, when you declare a variable storing a list, you don’t have to think about freing it when it’s no longer used, Python’s garbage collector does that automatically for you.
-
Multi-paradigm: Python supports many programming styles such as procedural, functional (FP), object orriented programming (OOP)…
-
Batteries included: Python ships with a large standard library, it includes anything that you may need from basic math utils to advanced collections such as Minimum heaps and queues.
How Your Code runs

When you run:
python3 hello.py # or python hello.py
The Python’s interpreter first reads and parses your code.
And then it compiles it to bytecode which is a compact, fast and optimized binary format of your code ,
After that, the interpreter executes it on the Cpython virtual machine (VM).
In order to optimize future runs of your scripts, the interpreter may save the bytecode of some parts of the script as “.pyc” binary files within a directory named “pycache”.
By default it saves the bytecode only for complex scripts that import multiple modules.
To enforce the compilation of our hello.py script run:
python3 -m py_compile hello.py # or python -m py_compile hello.py
-m Python’s CLI argument stands for module, here we are running the “hello.py” script using the pre-installed “py_compile” Python module.

Summary
Python’s 5 Key Characteristics
- Interpreted: code is executed by the Python interpreter.
- Dynamically typed: variable types are determined at runtime.
- Garbage collected: memory is managed automatically.
- Multi-paradigm: supports procedural, object-oriented, and functional programming.
- Batteries included: comes with a rich standard library.
How Python runs your code

How to Force a script to compile to bytecode (.pyc file)
python3 -m py_compile hello.py
Key Notes for Interviews
-
Python does compile your code to machine code as other languages like C or C++, it only compiles into an optimized format called bytecode and runs it right away line by line, while caching it for latter uses in
.pycfiles stored within the__pycache__directory. -
In brief, the Python interpreter is responsible for parsing your code, compiling it to bytecode, and executing it on the CPython Virtual Machine (VM).
-
Python’s dynamic typing and garbage collection make it easier to write code without manually managing types or memory.
Conclusion
Now you know what makes Python unique in the programming languages realm, and how your code is executed under the hood by the interpreter, we explain what’s happening starting from the source code parsing, and converting to bytecode, then running it on the CPython virtual machine.
In the next chapter, we’ll start writing Python code, and we will learn about variables and data types, the building blocks of every program and application out there.
Enjoyed this article?
I'm currently open to new roles, remote-first or international. If something resonated or you'd like to collaborate, I'd love to hear from you.
This article was originally published on https://sidaliassoul.com/blog/python-key-characteristics-and-how-your-code-runs/. It was written by a human and polished using grammar tools for clarity.