A Poorman's Rust Enum in Python for ThePrimeagen's Lexer

A couple of months ago, I came across a video where the prolific streamer and Netflix dev known online as the ThePrimeagen live-coded a simple lexer for an interpreter inspired by the book Crafting Interpreters by Robert Nystrom. If you’ve ever looked into what CPython actually does with your source code, you’ll know that it parses the code into an abstract syntax tree, converts the tree into bytecode instructions (i.e. those *....

August 12, 2023 · 7 min · 1423 words · Will Duke

Pretty Pipes for Perusable (and Reusable) Pandas Procedures

Pandas is a fantastic library for data analysis, but its syntax can be a bit jarring to the unfamiliar user, especially one coming from the R tidyverse ecosystem where the %>% (pipe) operator makes method-chaining powerful and preferred for most operations. It turns out that a similar syntax is totally possible in pandas with the pipe and assign methods! With these, you can make your pandas code much more readable and reusable....

September 22, 2022 · 4 min · 690 words · Will Duke

Solving Matt Parker's Wordle Puzzle in Seconds with iGraph

A few weeks ago, Matt Parker released a video where he posed a question he’d received from a viewer about the popular game Wordle: how many words can you try in a Wordle game without reusing a letter? At most, the answer can be 5 (25 letters total with one unused). So the question becomes: are there sets of five English words without any overlapping letters, and (while we’re at it) if so, how many?...

September 3, 2022 · 7 min · 1361 words · Will Duke

The Trouble with Notebooks

Notebooks are exceptionally popular among data scientists. So much so that many of my colleagues work largely in JupyterHub or Sagemaker. Notebooks provide a convenient enviroment for quick prototyping, and they feel natural for data scientists that (like me) don’t have a formal computer science background. That said, I’m convinced that we are using them in many cases where they aren’t worth the downsides, and even that the popular wisdom that they are a good place to get started quickly has it quite backwards....

July 28, 2022 · 5 min · 1058 words · Will Duke

Conway's Game of Life in Just a Few Lines with Python's Scientific Stack

Awhile back, I came across a video from one of my favorite channels, Numberphile, on Conway’s Game of Life. Turns out, it’s not a game you can actually “play,” beyond setting the initial state of a simulation that progresses via a set of very simple rules. Devised by the British mathematician John Conway in 1970, the game is composed of a grid of cells, each of which can be alive or dead....

May 3, 2022 · 9 min · 1708 words · Will Duke