Skip to content

Blog

#210: Cache Function Calls

If our application uses recursion, we may call the same function with the same values many times. When that function is side-effect free, we can save a lot of time by caching the result. And even better, in Python we can do that without much effort.

#209: Defaultdict

When we work with dictionaries that contains lists, we need to make sure that the list exists before we can add items. Or when we use a dictionary for counters, we must make sure that we have a value before we can increment it. While this can be done by hand, there is a much more elegant way in Python.

#207: Type Hints

Internally Python uses classes and therefore types everywhere. However, when we declare our methods, we omit the types and end up with limited functionality for our code editors. In this post we look at type hints and how they can improve our experience to write code.

#202: Rounding in Python

Python is usually a straightforward language without surprises. However, when you use the round() function you may run into some strange behaviour. Let us have a look at the specialities of round() and what is going on.

#201: How Much Cost a Print()?

A few weeks back we were running a data preparation script that took a long time to complete. The main part of the work should not take that much time, but somehow that script was sloooow. I expected that the print() statement for each record would have an impact on performance, but I had no indication of the magnitude. Is it significant? Or is it neglectable? Let us find out how big the impact can be.