How to Benchmark (Python) Code
A guide to benchmarking Python code, comparing tools like timeit and Docker for objective performance measurement.
Sebastian Witowski is an independent Python consultant, freelancer, and international speaker based in Poland. With 10+ years of experience—including work at CERN—he specializes in Python development for finance and energy trading, covering web development, ETL pipelines, and technical workshops.
55 articles from this blog
A guide to benchmarking Python code, comparing tools like timeit and Docker for objective performance measurement.
Benchmarking Python 3.11's performance improvements by testing common code patterns like loops, comprehensions, and sorting.
A tip on adding comments to shell commands to make them easier to search and reuse later, using examples with pytest and database objects.
A developer explains the decision to rewrite their personal blog from scratch using the 11ty static site generator, discussing its benefits and trade-offs.
A guide to managing multiple Python versions on your system using the pyenv tool for development and project isolation.
A collection of 25 IPython tips to help programmers solve Advent of Code puzzles more efficiently using interactive Python.
A Python tutorial comparing methods to remove duplicates from a list, focusing on performance and code clarity.
Compares Python's type() and isinstance() functions, explaining their differences, performance, and when to use each.
Explains Python membership testing using 'in' operator vs. for loops, with benchmarks showing performance differences.
Explains the best way to check for True/False in Python, comparing performance and recommending the PEP8-compliant 'if variable:' idiom.
A technical comparison of Python's list.sort() and sorted() functions, analyzing their performance with benchmarks and correcting common testing mistakes.
Compares Python for loops and list comprehensions, analyzing performance benchmarks and best use cases for filtering lists.
Compares Python's OrderedDict vs standard dict performance, explaining when and why OrderedDict is still useful.
Learn how to use Numba's @jit decorator to achieve massive speedups in Python code with minimal changes, demonstrated with a benchmark example.
A technical article comparing while and for loops in Python for finding numbers, with performance benchmarks and Python version considerations.
Compares the 'Ask for Forgiveness' (EAFP) and 'Look Before You Leap' (LBYL) coding philosophies, using Python file reading as an example.
A series exploring techniques to write faster Python code, covering idiomatic patterns, performance tools, and benchmarking.
A guide to creating an IPython extension to improve the %rerun magic command by handling exceptions during command replay.
A developer shares their favorite command-line interface (CLI) tools for productivity, including shells, search utilities, and system monitoring.
A guide to 18 useful VS Code plugins that enhance the Python development experience, from core language support to framework-specific tools.