Python + Pyright now do true match exhaustiveness checking

Does everyone already know about this? Am I just late to the party? I randomly discovered this, and it’s blowing me away. Background: why match & exhaustiveness checking is cool First, here’s a great run-down on Python 3.10’s match statement. But Rust’s “matches are exhaustive“. I’ve always thought this is amazing, almost magical: Rust knows…More

Reasons to use memoization

A recent Linked In post on memoization got a lot of questions and some pushback, saying that @var ||= function() is good enough. Here’s an example and my reasons for using memoization.More

The Iterate-and-Mutate Programming Anti-Pattern

Take a look at this small, typical code snippet: I call this the iterate-and-mutate pattern. It comes up all the time in code. But every time we see it, we should think about replacing it with a mapping operation, like this: (Ruby syntax) This code is “safer from bugs, easier to understand, and more ready…More