Skip to content

Latest commit

 

History

History
70 lines (51 loc) · 1.36 KB

README.md

File metadata and controls

70 lines (51 loc) · 1.36 KB

Why Python Is Slow (and When It Doesn't Matter)

Video: https://youtu.be/YrXYRiVGork
Written version: https://cloudexplainers.com/why-python-is-slow-and-when-it-doesn-t-matter/

Everything below ran for real in the video. Run it in a throwaway machine or container, never on a computer you care about.

Lab files

The machine the video used, as files you can build it from:

Commands, in the order the video runs them

The problem

# ana@laptop:~/shop$
python3 loop.py
gcc -O2 -o loop loop.c
./loop

Reason 1: the interpreter

# ana@laptop:~/shop$
python3 bytecode.py

Reason 2: everything is an object

# ana@laptop:~/shop$
python3 sizes.py

Reason 3: the GIL

# ana@laptop:~/shop$
python3 threads.py

How Python code goes fast

# ana@laptop:~/shop$
python3 builtin.py
python3 numpy_sum.py
pypy3 loop.py

When it doesn't matter

# ana@laptop:~/shop$
python3 web_request.py

From Cloud Explainers. Lab files are MIT licensed (see the repository's LICENSE).