Plurrrr

Sat 12 Dec 2020

Become shell literate

Shell literacy is one of the most important skills you ought to possess as a programmer. The Unix shell is one of the most powerful ideas ever put to code, and should be second nature to you as a programmer. No other tool is nearly as effective at commanding your computer to perform complex tasks quickly — or at storing them as scripts you can use later.

Source: Become shell literate, an article by Drew DeVault.

Regex literals optimization

The regex literals optimization avoids running the regex engine on parts of the input text that cannot possibly ever match the regex.

An example of a regex this can be applied to is \w+@\w+\.\w+, where the algorithm quickly finds the first @, then matches \w+ backwards to find the start of the match, and then matches \w+\.\w+ forward to find the end of the match. It then finds the second @, starting from the end of the previous match, and so on. This is a fairly naive (and incorrect) implementation, but it gives the idea of how it works.

Source: Regex literals optimization, an article by Esteban C. Borsani.

How Python object system works

As we know from the previous parts of this series, the execution of a Python program consists of two major steps:

  1. The CPython compiler translates Python code to bytecode.
  2. The CPython VM executes the bytecode.

We've been focusing on the second step for quite a while. In part 4 we've looked at the evaluation loop, a place where Python bytecode gets executed. And in part 5 we've studied how the VM executes the instructions that are used to implement variables. What we haven't covered yet is how the VM actually computes something. We postponed this question because to answer it, we first need to understand how the most fundamental part of the language works. Today, we'll study the Python object system.

Our Christmas tree

In the evening we decorated the Christmas tree that was delivered by the end of the afternoon to our house. Because the tree was quite large we had to move around our furniture to make space.

Our Christmas tree
Our Christmas tree.