4 ms·
I'm curious, while writing the commentary, did you feel conflicted about what perspective to write from? The evaluation order of code isn't linear, it's more li
by tunesmith 4y ago
I'm curious, while writing the commentary, did you feel conflicted about what perspective to write from? The evaluation order of code isn't linear, it's more like a directed acyclic graph (or at least a directed cyclic graph that eventually terminates), and so what you want to write for a certain area of code might change depending on how it is called.
- FrenchyJiby 4y agoHey, OP here. Good question! Indeed, I tried initially to write this as a top-to-bottom thing that tangles in the "obvious" (sequential) way. This proved limiting quickly because of my intention to run formatting/linting tools (secondary objective of "showcase modern Python" conflicted with the literate programming one). Successive code blocks for the same file were separated by a single line, but Python functions require 2 lines of separation to match PEP8 formatting. Similarly, some of the TDD aspect of "define a stub function to get a red test" meant that to re-write the function later, I'd have to overwrite an "old" (in narrative timeline) codeblock, so I would need out-of-order tangling anyway. I did consider if I really wanted to show the out-of-order tangling blocks, as it looked a little ... unclean? But eventually it felt like a good enough review/summary step of each feature, debriefing on the resulting code. The real value of this out of order tangling was stuff like adding the @cache decorator way after initially definining the function itself, felt like a big win. A few last-second edits (see the git history, it's fun...) of the code to fix bugs/warts made me re-visit some sections, and as I mention in sibling comment, I definitely had to reconciliate the tension "narrative-as-I-built-it" vs "proper-but-ex-post-facto".