Category: Programming
-
Python dict key ordering
Due to dicts preserving the order of key insertion, they’re another example of objects that may have == True but with other methods yielding different values: How does Python implement remembering key insertion order? Raymond Hettinger’s 2017 talk Modern Python Dictionaries A confluence of a dozen great ideas talks about how the ordering is a…
-
equal unequal Counters
As demonstrated above, collections.Counter.most_common orders elements with equal counts in order of first appearance: “Elements with equal counts are ordered in the order first encountered”. But == looks at set equality. Handy for checking for palindromes without doing a sort (and so hopefully O(n) vs O(n log n)): Counter(s) == Counter(t). Just slightly disconcerting to…
-
__builtin_popcountg
Looking at https://en.cppreference.com/cpp/utility/bitset/count, I was intrigued to see popcount mentioned in the “See also” section. Handy. That made me curious to see how the stdlibs choose to implement it. Here it is for Clang: libcxx/include/__bit/popcount.h For gcc: libstdc++-v3/include/std/bit So, there’s at least one configuration where they end up both calling something called __builtin_popcountg. What are…
-
Progressive rescaling does make a difference
My dad learned calculus from this book: Practical mathematics, theory and practice with applications to industrial business and military problems. I wanted to include a photo of the title page from his copy of it in a little biography we’re working on for him, but I ended up with jaggies when using my scaleimage tool.…
-
Where is zip?
Download a copy of CPython’s source: Where is zip implemented? Looks promising! This looks like a good start point — defining it along with the other builtins inside _PyBuiltin_Init in Python/bltinmodule.c: where _PyBuiltin_Init gets called in Python/pylifecycle.c here: where pycore_init_builtins called in Python/pylifecycle.c here: where pycore_interp_init gets called in Python/pylifecycle.c here: where new_interpreter gets called…
-
Getting text from some seed packet labels
I’ve been enjoying following along with Simon Willison as he plays with LLMs via his llm tool but haven’t tried it out yet. Now I have a small task in mind — I recently planted some seeds, taking a photo of each seed packet while I was at it. I’d like to extract the plant…
-
Extracting Google Scholar metadata
I wanted to find the number of citations per year for a paper from my dad, at least per Google Scholar. Hacking around, here’s a little JavaScript to get it per results page: How would you do this? Is there a nicer way to do it? There were 12 results pages. I was paranoid about…
-
My second WP plugin
I’m starting to read “WordPress Plugin Development Cookbook – Third Edition”. The first example does nothing other than make a do nothing plugin visible in the admin page, but the second example already allowed for some fun. I’m happy with how psychedelic this turned out: I won’t add it here though. References mentioned:
-
“How to stick with your projects, even when they’re janky”
There’s a lot to reflect on from this 2025 talk from Jeaye Wilkerson, creator of jank, a Clojure dialect targeting C++ interop: “How to stick with your projects, even when they’re janky”: I’ve not really done his talk full justice, but in the spirit of focusing on shipping, I’m publishing this as is. 🙂