RSSAmplifier

Blog

Andrew Brookins

The collected essays of Andrew Brookins, published from 2009 to the present.

andrewbrookins.comRSS feed ↗10 posts

Latest posts

The Collapse of Space

An analog watch shows time on a circular plane. In order to understand the time, your eye has to navigate a circle. Time becomes the circle, scaled to the size of the circle. If you have a digital watch, you can try this out by setting your watch to an analog face. You scan the circle to find the time — for example, 10:15 pm. Or is it 10:16? Hard to say with an analog watch, sometimes. Now…

How to Ride a Bike in the Suburbs or Die Trying

Above all, you need grit. Biking in the suburbs means exposing yourself to constant danger. But as you navigate a concrete world hostile to unprotected human life, you may find pockets of nature and corners of yourself that you’d forgotten. All suburbs are different, but they share common features that you must prepare for. Few, if any, bike lanes, poor sidewalk infrastructure, narrow shoulders,…

High Availability, Replication, and Failover Explained with Stuffed Animals

My 2-year-old daughter’s favorite stuffed animal, “Meow-Meow,” is a critical service in my house, so my wife and I run a highly available three-node Meow-Meow cluster. Despite being simple, this Meow-Meow cluster can help explain the essential parts of highly available systems: High availability Replication Observability Consensus Failover The split-brain problem Active-active replication I’m…

What is Python's Default Hash Algorithm?

A friend of mine wondered recently, What is Python’s default hash algorithm? I knew that Python objects could implement a __hash__() method, but not what the default hash algorithm was, so I dug into this question a bit. NOTE : If you’re short on time, the answer is SipHash . Read on to learn more about what Python uses hashing for and why Python uses the SipHash algorithm specifically. What is…

Poetry Is My Favorite Python Dependency Manager

A Story February 2021. Maintainers of the cryptography package release a new version that depends on Rust to build. Within hours, CI pipelines across the world start burning, and the hallucinogenic smoke awakens internet trolls. What happened, and how does it relate to Poetry , the popular Python dependency manager? Pin Your Transitive Dependencies, My Friends I’m going to ignore the Rust part of…

Rewriting an API to Use FastAPI: Benchmarks and Lessons Learned

Last week at work, I rewrote an API to use FastAPI and as much async Python as possible. Then I benchmarked the old and new versions of the API to see which was truly fastest. The summary? FastAPI and async Python made my API much faster . Check the rest of this article for the longer story, including how the rewrite went, bugs I ran into, and benchmarks. About FastAPI FastAPI is an async Python…

Scaling Django with Postgres Read Replicas

Replication is a feature of PostgreSQL that you typically use to achieve high availability by running copies of a database that are ready to take over if your primary database fails. However, you can also use replication to make your Django applications faster. In this post, I’ll explain how to configure Django to query read-only Postgres replicas, allowing you to scale your database read…

Building Implicit Interfaces in Python with Protocol Classes

Python 3.8 shipped one of the coolest features I’ve seen in a recent Python version: protocol classes. This feature lets you build interfaces and check that objects satisfy them implicitly, much like you can in Go. You might call this static duck-typing . Intrigued? Let’s check out how protocol classes work by writing some code. The Five-Minute Version If you just want to see how this works, check…

Why Does Python Have a len() Function?

New Python users are often surprised to learn that you call a global function named len() to get the number of items in a container. For example, if you’re used to a language like Ruby or Java, you might expect a Python list to have a length() method, but no – to get a list’s length, you call len(my_list) . Now, of course, beauty is subjective. But why does Python use this approach instead of…

Recording Pro Audio and Video at Home with iPads and iPhones

In January, I started a new job writing and producing technical education videos. I was supposed to record these videos in a studio in Mountain View, California, but COVID-19 had other plans. So, for the past six months, I’ve had to learn how to record professional audio and video from home, using an iPad Pro and iPhone 8. In this post, I cover the tools, apps, and techniques I use to get my job…