Programming Leftovers
-
Nicolas Fränkel ☛ Kotlin Coroutines and OpenTelemetry tracing
Indeed, the @WithSpan annotation works flawlessly in conjunction with coroutines since some time already. However, it made me think about the underlying workings of OpenTelemetry. Here are my findings.
-
University of Toronto ☛ A downside or two of function keyword arguments (and default values)
Technically you can have keyword arguments without supporting optional arguments or default values, but I don't think very many languages do. The languages I've seen with this generally tend to make keyword arguments optional and then sometimes let you set a default value if no value is supplied (otherwise an unsupplied argument typically gets a zero value specific to its type or the language; for example I believe Emacs Lisp makes them all nil).
-
James G ☛ How to implement a time-based LRU cache in Python
There are two caching strategies that are commonly used: time-based and Least Recently Used (LRU). You can combine them both to achieve a more desirable result.
Let’s talk about both time-based and LRU caches, how they work, what properties they have, and when you may want to implement a hybrid time-based LRU cache.
-
Tim Bradshaw ☛ Wild pathnames in Common Lisp
The underlying problem is that on many platforms pathnames which ‘look like’ they contain wildcards are perfectly legal pathnames to the filesystem. So, on Unix & related systems [foo].* is a legal filename. On these platforms wildcard handling is generally implemented in a library, or often in multiple semi-compatible libraries1.
-
James G ☛ Introduction to consensus modeling in Python
Consensus algorithms allow computer scientists and data analysts to answer a question based on information from several data sources. These data sources may be independent, or data taken from the same source but at different time frames.
-
Alex Gaynor ☛ Safer C++
I am an unrepentant advocate for migrating away from memory-unsafe languages (C and C++) to memory safe languages in security-relevant contexts. Many people reply that migrating large code bases to new languages is expensive, and we’d be better off making C++ safer. This is a reasonable response, after all there’s an enormous amount of C++ in the wild. Even on an incredibly aggressive timeline for replacing every line of C++ in the world with Rust or Swift or Go, we’ll have a lot of C++ attack surface for a long time. So even if you’re a memory-safe languages advocate, achieving a safer C++ is a worthwhile goal.
-
Python
-
James G ☛ Python pattern: Using defaultdicts to initialise dictionaries
The collections.defaultdict Python dictionary automatically adds an empty value of the default type supplied whenever a new item is added to the dictionary. defaultdict dictionaries behave like a Python dictionary, except with the property that if a key doesn’t exist, a default value is added so that you can manipulate the value without checking for the presence of the key.
-