Is 100% coverage worth it ?

🧵The debate The debate over targetting 100% code coverage has long divided software engineers. Some believe it’s worth the time to test everything while others argue that aiming 80% or 90% is sufficient. Achieving such high coverage is clearly a significant amount of work, especially on a legacy/non-trivial codebase. I recently had to start a new project from scratch and asked myself the question: should I bother to aim for 100% coverage or should I settle for an arbitrary threshold like 90% ? ...

June 14, 2024

Why I still write Synchronous APIs

Async programming in Python had a lot of attraction in the recent years. Python 3.4 was released in 2014 and added the asyncio module. This enabled a great way to write async code but came with a new syntax and most libraries that wanted to be compatible had to undergo a big rewrite to enable this (you can check the great post What color is your function to understand why). We’re now ten years after the first asyncio release, and while the ecosystem still feels a bit fragmented, most of the time you can find an async library for your usecase (either librairies have adopted async/await or new librairies were born to fill the gap). ...

May 2, 2024

Syscall in Python

What is a Syscall ? 🔎 Syscall are the main way for program to communicate with the Operating System. Program usually run in userspace and are limited in the action they can do. For safety reason many low level actions are handled by the kernel. As soon as you want to do something meaningful (print something to stdout, read something from a hard drive, send something on the network, etc) you have to make a syscall to communicat with the kernel to do it. ...

January 9, 2024

Composition and Dependency Injection

Back at Europython this year, I attended this very good talk on composition by Hynek Schlawack, which clicked on many level with how I code nowadays. I was never a huge fan of oriented object programming and inheritance in particular. I really recommend to watch the talk if you feel the same ! But I recently learned that when trying to apply composition together with dependency injection, things can become a bit more complex 😶 ...

November 6, 2023

Pytest Gotcha

Pytest is a great library and has become my default choice for any testing I have to do in Python. It’s really easy to start with it, just create some function starting with test_ containing some assert inside a file and run pytest on this file. Pytest will auto-discover the test function and run it, providing a detailed explanation in case of failure ! However, there’s one small pitfall I noticed several times during code review, which is the following usage: ...

January 19, 2022