Skip to main content
  1. Posts/

Python Numbers Every Programmer Should Know

🐍 How fast is Python, really?

Did you know opening a file takes 10x longer than a simple SQLite select? Or that importing FastAPI costs 104 ms, while summing 1,000 integers takes only 1.9 μs?

Michael Kennedy published a benchmark cheat sheet for Python 3.14.2 on a Mac Mini M4 Pro. Numbers organized by category:

⏱️ Basic operations:

  • Attribute read: 14 ns
  • Dict lookup: 22 ns
  • list.append(): 29 ns
  • f-string formatting: 65 ns
  • Exception raised + caught: 140 ns

💾 Memory:

  • Float: 24 bytes
  • Small int (cached): 28 bytes
  • Empty string: 41 bytes
  • Empty list: 56 bytes
  • Empty dict: 64 bytes

🌐 Web frameworks (req/sec):

  • Starlette: 124.8k | FastAPI: 115.9k | Django: 55.4k

📦 Key tip: __slots__ dramatically reduces memory when storing thousands of class instances.

Quick explanation
#

Just as systems programmers know RAM is 100x faster than disk, Python developers should internalize their own reference numbers. This guide answers: dict or set? Is orjson worth it? When does async actually matter? With this data, you make informed performance decisions.

More information at the link 👇

Also published on LinkedIn.
Juan Pedro Bretti Mandarano
Author
Juan Pedro Bretti Mandarano