kasku.net

What's black, white, and red all over?

links

Gotta Go Fast

https://en.algorithmica.org/hpc/ hosts "Algorithms for Modern Hardware", an "an upcoming high performance computing book [...] by Sergey Slotin". I found it while looking for material on optimising matrix multiplication, since mathematical software is so much faster than just writing the formula into a program. While the book itself is incomplete, it looks like that only means that some sections haven't been written yet. The existing sections are perfectly well fleshed out and definitely useful.

While I'm at it I'll also link "Is Parallel Programming Hard, And, If So, What Can You Do About It?" by Paul E. McKenny. It's very readable — I'd almost call it light reading, It never feels like anything is made more complicated than it has to be, which is a welcome relief compared to some other material. If you've ever wondered "why couldn't the author just have said that?" after understanding a simple idea underlying some complicated prose, you'll be happy to receive the simple idea directly for once.

lxml

I've been using lxml for a few things on this site, which has been going well. I'm mostly using interfaces from lxml.etree, namely the ElementTree and Element classes, along with the E-constructor from lxml.builder.

  • You can parse your XML document into an ElementTree with etree.ElementTree(etree.fromstring(doc)).
  • You can construct elements with the E-constructor, for example E("span", "your text here") will correspond to <span>your text here</span>. The examples in the documentation are good, so I won't dwell on this. You can also access the element's data via the corresponding attribute, for example .tag or .text.
  • You can search for elements with a given tag using the .find() or .iter() methods on your tree. Once you have a matching element, you can use methods like .append(), .addnext(), or .replace() to add a new element into the document.

This section of documentation explains the rules for matching tags, which apply to other methods like .find() as well. There are other things you can do with lxml, and other things you can do with the parts of it I've listed, but this was what I needed to do what I wanted.

blog

the wayland logo with a red background

Wayland

Every now and then (though especially now) I see people arguing about X vs Wayland. I don't particularly care if people prefer one or the other, but a lot of the things people say about Wayland are wrong, or at least give an incorrect impression through omission, confusing terminology, or otherwise. Since those impressions can cause concrete problems, this is my attempt to clarify things.