week 21, 2020

Latency in Asynchronous Python

This week I was debugging a misbehaving Python program that makes significant use of Python’s asyncio. The program would eventually take very long periods of time to respond to network requests. My first suspicion was a CPU-heavy coroutine hogging the thread, preventing the socket coroutines from running, but an inspection with pdb showed this wasn’t the case. Instead, the program’s author had made a couple of fundamental mistakes using asyncio. Let’s discuss them using small examples.

Source: Latency in Asynchronous Python, an article by Chris Wellons.

Five tips to be a more effective command-line user

This article intends to be helpful for those who are already command line (CLI) users. Complete beginners are of course encouraged to read on, even though they may not grasp all the advantages immediately and perhaps there is a lot of other more important things to learn when starting. On the other hand, I expect long time CLI users to already work similarly. I do hope they might also find interesting tricks to adopt.

Source: Five tips to be a more effective command-line user, an article by Cosimo Streppone.

Optional JSON fields in Go

One common kind of data stored in a configuration file is options. In this post, I'll talk about some nuances we have to be aware of when storing options in JSON and unmarshaling them to Go.

Specifically, the most important difference between options and any other data is that options are often, well... optional. Our program can have a large number of possible configuration options, but we may want to configure any particular invocation with only a subset - leaving all the others at their default values.

Source: Optional JSON fields in Go, an article by Eli Bendersky.

Bash Romance

It’s not a particularly new or exciting take to say that we’ve outgrown Bash. The Unix shell environment was novel and powerful in its day, but its age is really starting to show.

Source: Bash Romance.

Python Caches Integers

An integer in Python is not a traditional 2, 4, or 8-byte implementation but rather it is implemented as an array of digits in base 230 which enables Python to support super long integers. Since there is no explicit limit on the size, working with integers in Python is extremely convenient as we can carry out operations on very long numbers without worrying about integer overflows. This convenience comes at a cost of allocation being expensive and trivial operations like addition, multiplication, division being inefficient.

Source: Python Caches Integers, an article by Arpit Bhayani.

Adam's Acanthoscurria geniculata arrived

Today, shortly after Adam returned from school, one of his birthday presents finally arrived; a female Acanthoscurria geniculata. I had ordered this tarantula the 6th of May, 2020 with Robert of Fatbob's Exotics:

  • 0.1 Acanthoscurria geniculata 2,5-3cm body €25

Together with shipping within the Netherlands it came down to €32. Originally, Adam wanted to have a female Brachypelma hamorii but when I contacted Robert the 5th of May this tarantula was no longer available.

Adam holding the vial with his female Acanthoscurria geniculata
Adam holding the vial with his female Acanthoscurria geniculata.

Due to the colder nights it took a while before Robert could ship the spider safely. But yesterday it got picked up by DPD and today it arrived. Not on time for Adam's birthday, which was the 12th of May, so he had been asking now and then "When is my tarantula coming?"

Female Acanthoscurria geniculata on Adam's hand
Female Acanthoscurria geniculata on Adam's hand.

For the terrarium I drilled plenty of holes in two sides of a plastic box and several more in the lid. Together with Adam I added plenty of substrate; slightly moist coco peat. I had also cut a cork tube in half, which Adam added, together with two plastic plants. Finally, I added a plastic bottle lid with water to provide a source of moisture to the spider.

Acanthoscurria geniculata in its terrarium
Acanthoscurria geniculata in its terrarium.

We tried to feed the tarantula a mealworm larva, Tenebrio molitor, but it was not interested. In my experience sometimes tarantulas accept food after travelling and sometimes they don't. Later in the afternoon when I checked the terrarium I noticed that she had been moving substrate out of the cork tube and made a nice pile next to it.

Close up of the female Acanthoscurria geniculata
Close up of the female Acanthoscurria geniculata.

In the evening Adam and I checked again, but she was still well hidden in her new burrow. We also tried to feed his Heterometrus petersii. While the scorpion did pick up the mealworm I put next to it, and even held it for a while, it was too stressed out because I had lifted the piece of wood it normally hides under to actually eat it. Adam and I decided to try again tomorrow. Adam is a little worried about his scorpion since it hasn't been eating since we bought it, the 23rd of February, 2020 at the Invertebrate Show in Harmelen.

We did leave a pre-killed mealworm next to the burrow entry of his tarantula, though. Let's see if it's gone tomorrow.

Python performance: it’s not just the interpreter

I have a particular view of Python performance from my experience on the Pyston project, and since this view is somewhat nonstandard I wanted to take some time to explain it and give a motivating example.

A common explanation for Python's low performance is that it is an interpreted language. In this post I hope to show that while the interpreter adds overhead, it is not the dominant factor for even a small microbenchmark. Instead we'll see that dynamic features -- particularly, features inside the runtime -- are to blame.

Source: Python performance: it’s not just the interpreter, an article by Kevin Modzelewski.

What is Nix

The most basic, fundamental idea behind Nix is this:

Everything on your computer implicitly depends on a whole bunch of other things on your computer.

  • All software exists in a graph of dependencies.
  • Most of the time, this graph is implicit.
  • Nix makes this graph explicit.

Source: What Is Nix, an article by Burke Libbey.

Defensive BASH Programming

Here is my Katas for creating BASH programs that work. Nothing is new here, but from my experience pepole like to abuse BASH, forget computer science and create a Big ball of mud from their programs. Here I provide methods to defend your programs from braking, and keep the code tidy and clean.

Source: Defensive BASH programming, an article by Kfir Lavi.

Hapalopus sp. Colombia large form eating a mealworm

In the afternoon I gave the smallest of the tarantulas I keep, a Hapalopus sp. Colombia large form sling, a small mealworm, Tenebrio molitor. Even though the mealworm was larger than the tarantula, as soon as I dropped it next to it, the tarantula attacked the larva, wrestled with it, and subdued it.

Hapalopus sp. Colombia large form eating a mealworm
Hapalopus sp. Colombia large form eating a mealworm, Tenebrio molitor.

I keep this species since April the 7th, 2020. And while I have attempted to give it pre-killed mealworms before as far as I know this is the first time it actually eats in my care.

This spider has the common name "Pumpkin Patch" tarantula because of the orange pattern on the abdomen. For more information on this dwarf tarantula read Hapalopus sp. Colombia – The “Pumpkin Patch” by Tom Moran.

Let SOcket CAT Be Thy Glue Over Serial

I previously wrote how to configure minicom to connect to a device over serial UART. In that post I mentioned that minicom might not be the best tool for the job. Consider that minicom is adding a lot of unnecessary complexity. If you think about it, we are taking a command line utility intended for communicating with modems, stripping all that functionality away so that we are left with nothing more than a terminal emulator that knows how to connect to a foreign TTY. Yet, we are probably running minicom from a perfectly capable terminal emulator such as xterm. All we need is a way of connecting our terminal emulator to the target serial port in raw mode. As long as the device side is running a login on the receiving end, we can simply let our terminal emulator do what it was designed for.

Source: Let SOcket CAT Be Thy Glue Over Serial, an article by Trevor Wilson.

Chromatopelma cyaneopubescens eating a mealworm

In the afternoon I checked on the Chromatopelma cyaneopubescens sling I keep and noticed that it was resting on the part of the substrate I keep slightly moist. Because it was quite dry I added some water with a dosing syringe expecting the tarantula to take a drink but instead it attacked the water. Time to try to feed it, so I gave it a small mealworm larva, Tenebrio molitor.

Chromatopelma cyaneopubescens eating a mealworm
Chromatopelma cyaneopubescens eating a mealworm, Tenebrio molitor.

I have been taking care of this spiderling since February the 23rd, 2020 when I bought it at the Invertebrate Show in Harmelen.

This tarantula has the common name "Green Bottle Blue" (GBB for short) and is considered a beginner species. For more information on this tarantula read C. cyaneopubescens (or the GBB) by Tom Moran.