Create multi-dimensional arrays in pure Python: The Correct Way

The problem Yesterday I wasted about half an hour chasing a bug because I was mindlessly generating a 5x5 matrix with the list repeat syntax, aka list * integer in pure Python: n = 5 array = [[0] * n] * n When I tried to flip some specific bits in this matrix, I observed that entire columns got flipped, instead of just one element: array[0][0] = 1 print(array) # Output: [[1, 0, 0, 0, 0], # [1, 0, 0, 0, 0], # [1, 0, 0, 0, 0], # [1, 0, 0, 0, 0], # [1, 0, 0, 0, 0]] In retrospect, the behaviour makes sense, but in the middle of a much larger program, it was a bit hard to find....

September 5, 2021 · 6 min · Lim H.

PR review, as a H.U.M.A.N

In software engineering, one of the most frequent communication channels is Pull Request (PR) review. Over the years, I have distilled a list of guiding principles for myself when reviewing PRs, apart from double-checking for correctness. The goal is, as one of my mentors put it, to apply human decency in the review process. I have expanded “H.U.M.A.N” into an acronym, which stands for Helpful, Understanding, Meticulous, Appreciative and Necessary:...

July 1, 2021 · 2 min · Lim H.

10 random things I have learned about mental health in the last 10 years

Yesterday 10.10.2020 was the World Mental Health Day with the theme “mental health for all”. I sent this note to a few friends and they suggested I should share it with a wider audience because other people might find it useful. Disclaimer: I’m not a doctor. I’m just passionate about this topic, because in the last 10 years, I have personally seen the human mind break before my eyes - and sometimes behind my eyes - in the most frightening ways imaginable....

October 10, 2020 · 14 min · Lim H.

Introducing Kedro Hooks

This is an article two colleagues and I wrote on QuantumBlack’s Medium blog introducing a new feature on Kedro, our open-source data pipelining framework.

June 10, 2020 · 1 min · Lim H., Kiyohito Kunii, Jo Stichbury

Dataclass field metadata: Pythonic equivalence of Go struct tag

1. What is Golang’s struct tag Recently I have been writing some Go and there is a particular language feature in Go that I really like: struct tag. Basically, a struct tag is just an arbitrary string literal that you can attach to a struct, which later on you can decode and turn into something useful via reflection. If that still sounds too cryptic, consider this example: type MyAwesomeGoServiceConfig struct { Host string `envconfig:"SERVICE_HOST" another_random_tag:"amazing"` Port string `envconfig:"SERVICE_PORT" this_is_seriously_cool:"agree"` } The code above, apart from sounding uncharacteristically upbeat, is 100% valid Golang:...

May 18, 2019 · 4 min · Lim H.