RSSAmplifier

Blog

death and gravity

death.andgravity.comRSS feed ↗54 posts

Latest posts

reader 3.26 released – discovery, exports, demo

Hi there! I'm happy to announce version 3.26 of reader , a Python feed reader library. What's new? # Here are the highlights since reader 3.24 . Feed autodiscovery # reader now discovers feeds automatically – instead of searching for feed links, just add the website URL, and the web app will suggest any feeds it finds. Behind the scenes, this is enabled by the autodiscover plugin, which stores…

Ordered key sharding in DynamoDB

...in which we find out how to make a sorted index when the data doesn't fit on a single DynamoDB partition.

DynamoDB crash course: part 3 – design patterns

This is the last part of a series covering core DynamoDB philosophy, concepts and patterns; the goal is to help you understand idiomatic usage and trade-offs in under an hour. Today, we're looking at data modeling patterns – how to manage the complexity that arises from DynamoDB being as low level as it is.

reader 3.24 released – help, multi-user updates

Hi there! I'm happy to announce version 3.24 of reader , a Python feed reader library. What's new? # Here are the highlights since reader 3.23 . Context-sensitive help # In lieu of a tutorial mode, the web app now offers guidance to new users, and has a basic context-sensitive help system. Here's some screenshots: new user / empty state context-sensitive help also help Structured logging # reader…

reader 3.23 released – OPML, hosted reader intro

Hi there! I'm happy to announce version 3.23 of reader , a Python feed reader library. What's new? # Here are the highlights since reader 3.22 . OPML support # reader can finally import and export feeds as OPML subscription lists! I initially wanted to use listparser , but I ended writing my own reader.opml module, mainly to keep dependencies down; it's just ~100 lines of code, including the…

Learn Python object-oriented programming with Raymond Hettinger

Even if you haven't heard of Raymond Hettinger, you've definitely used his work, bangers such as sorted(), collections, and many others. His talks had a huge impact on my development as a software engineer, are some of the best I've heard, and are the reason *you should not be afraid of inheritance* anymore.

reader 3.22 released – new web app

Hi there! I'm happy to announce version 3.22 of reader , a Python feed reader library. What's new? # Here are the highlights since reader 3.20 . New feed reader web app # The new web application is done! Features include: add / list / filter / delete feeds list / filter articles mark articles as read / (un)important article view custom feed titles dark mode In the next releases, I'll be adding…

DynamoDB crash course: part 2 – data model

This is part two of a series covering core DynamoDB philosophy, concepts and patterns; the goal is to help you understand idiomatic usage and trade-offs in under an hour. Today, we're looking at the DynamoDB data model – what the main abstractions are, what you can do with them, and how they scale.

DynamoDB crash course: part 1 – philosophy

This is part one of a series covering core DynamoDB philosophy, concepts and patterns; the goal is to help you understand idiomatic usage and trade-offs in under an hour. Today, we're looking at what DynamoDB is and why it is that way.

reader 3.20 released – we're so back

Hi there! I'm happy to announce version 3.20 of reader , a Python feed reader library. What's new? # Here are the highlights since reader 3.16 . Web app re-design # Earlier this year, I started a web app re-design based on htmx and Bootstrap . I only had time for the main page, but it turned out pretty nice, and I've been using it ever since. What is new is that I now have free time and some…

Announcing asyncio-thread-runner: you can have a little async (as a treat)

Back in 2023, we made a thing for running async code from sync code. I'm happy to announce that it is now available on PyPI as asyncio-thread-runner.

Inheritance over composition, sometimes

Last time, we built a hybrid concurrent.futures executor using inheritance. Today, we're building it again (twice!) using composition and functions only, to figure out which way is better and why. Consider this a worked example.

Process​Thread​Pool​Executor: when I‍/‍O becomes CPU-bound

...in which we build a hybrid concurrent.futures executor that runs I‍/‍O bound tasks on all available CPUs, thus evading the limitations imposed by the dreaded global interpreter lock on the humble ThreadPoolExecutor.

reader 3.16 released – Archived feed

Hi there! I'm happy to announce version 3.16 of reader , a Python feed reader library. What's new? # Here are the highlights since reader 3.15 . Archived feed # It is now possible to archive selected entries to a special "archived" feed, so they can be preserved once the original feed is deleted; this is similar to the Tiny Tiny RSS feature of the same name (which is where I got the idea in the…

reader 3.15 released – Retry-After

Hi there! I'm happy to announce version 3.15 of reader , a Python feed reader library. What's new? # Here are the highlights since reader 3.13 . Retry-After # Now that it supports scheduled updates , reader can honor the Retry-After HTTP header sent with 429 Too Many Requests or 503 Service Unavailable responses. Adding this required an extensive rework of the parser internal API , but I'd say it…

reader 3.13 released – scheduled updates

Hi there! I'm happy to announce version 3.13 of reader , a Python feed reader library. What's new? # Here are the highlights since reader 3.12 . Scheduled updates # reader now allows updating feeds at different rates via scheduled updates . The way it works is quite simple: each feed has an update interval that determines when the feed should be updated next; calling update_feeds(​scheduled​=True)…

reader 3.12 released – split search index

Hi there! I'm happy to announce version 3.12 of reader , a Python feed reader library. What's new? # Here are the highlights since reader 3.10 . Split the search index into a separate database # The full-text search index can get almost as large as the actual data, so I've split it into a separate, attached database, which allows backing up only the main database. (I stole this idea from One…

This is not interview advice: a priority-expiry LRU cache in Python without heaps or trees

Today we're implementing a least recently used cache with priorities and expiry, using only the Python standard library. This is a bIG TEch CoDINg InTerVIEW problem, so we'll work hard to stay away from the correct™ data structures, but we'll end up with a decent solution anyway!

reader 3.10 released – storage internal API

Hi there! I'm happy to announce version 3.10 of reader , a Python feed reader library. What's new? # Here are the highlights since reader 3.9 . Storage internal API # The storage internal API is now documented! This is important because it opens up reader to using other databases than SQLite. The protocols are mostly stable, but some changes are still expected. The long term goal is full…

When to use classes in Python? When you repeat similar sets of functions

Having trouble figuring out when to use classes? In this article, we look at another heuristic for using classes in Python, with examples from real-world code, and some things to keep in mind.

reader 3.9 released – update hook error handling

Hi there! I'm happy to announce version 3.9 of reader , a Python feed reader library. What's new? # Here are the highlights since reader 3.7 . Better handling of unexpected update errors # Unexpected exceptions raised by update hooks , retrievers , and parsers are now wrapped in UpdateError, so errors for one feed don't prevent others from being updated . Also, hooks that run after a feed is…

Running async code from sync code in Python

So, you're doing some sync stuff. But you also need to do some async stuff, without making *everything* async. Hint: asyncio.Runner will get you at least part of the way there.

reader 3.7 released – contributor docs

Hi there! I'm happy to announce version 3.7 of reader , a Python feed reader library. More importantly, reader has reached 300 stars on GitHub! What's new? # Here are the highlights since reader 3.4 . Contributor documentation # reader now has contributor documentation ! If you want to help or you're just curious where it's all going, check out the roadmap and the reader philosophy . Thank you to…

Why you should still read the docs

Do you feel you're fighting your tools? Do you feel you're relying too much on autocomplete and inline documentation? tl;dr: Most good documentation won't show up in your IDE – rather, it is about how to use the library, and the problem the library is solving.

Announcing linesieve: an unholy blend of grep, sed, awk, and Python, born out of spite

Java is notoriously verbose, especially when used in a serious Enterprise Project™ ...so naturally, I made linesieve, a Python text munging tool to split output into sections and match/sub/split with the full power of Python's re module.

Limiting concurrency in Python asyncio: the story of async imap_unordered()

So, you're doing some async stuff, repeatedly, hundreds of thousands of times. How do you *not* do it all at once? Hint: asyncio.Semaphore is not always the best way, despite what Stack Overflow may tell you ;)

yaml: while constructing a mapping found unhashable key

... in which you'll find out what "while constructing a mapping found unhashable key" PyYAML errors mean, why do they happen, and what you can do about it.

Caching a lot of methods in Python

... in which you'll learn how to cache a lot of methods in Python, even for objects created by someone else. Did you know that, contrary to popular belief, Python programmers can have a little monkey patching as a treat?

reader 3.4 released – 5 years, 2000 commits

reader, my Python feed reader library, is 5 years old; since this is a special occasion, I thought I'd share a few thoughts on the journey so far.

Has your password been pwned? Or, how I almost failed to search a 37 GB text file in under 1 millisecond (in Python)

... in which we check if your password has been compromised in many inconvenient ways, in a tale of destruction, obsession, and self-discovery.

reader 3.0 released – multithreading

Hi there! I'm happy to announce version 3.0 of reader , a Python feed reader library. This release removes a number of deprecated methods and attributes, for a cleaner, more consistent API. See the changelog for details. Contents 2.x recap Unified tag API + entry and global tags Search enabled by default Statistics User-added entries Twitter support Read time Improved duplicate handling Memory…

reader 2.14 released – Twitter, read time

Hi there! I'm happy to announce version 2.14 of reader , a Python feed reader library. What's new? # Here are the most important changes since reader 2.11 ! Twitter support # You can now use reader to follow Twitter accounts . You still need a Twitter account to get a bearer token, but after that, https://twitter.com/user works like any other feed. Each thread corresponds to an entry. Threads are…

The unreasonable effectiveness of f‍-‍strings and re.VERBOSE

... in which we look at one or two ways to make life easier when working with Python regular expressions.

reader 2.11 released – metadata is tags

Hi there! I'm happy to announce version 2.11 of reader , a Python feed reader library. What's new? # Quite a lot happened since reader 2.5 ! Unified tag API + entry and global tags # Tags and metadata are now the same thing, generic resource tags : >>> reader . get_tag ( feed , 'one' , 'default' ) 'default' >>> reader . set_tag ( feed , 'one' , 'value' ) >>> reader . get_tag ( feed , 'one' )…

yaml: could not determine a constructor for the tag

... in which you'll find out what "could not determine a constructor for the tag" PyYAML errors mean, why do they happen, and what you can do about it.

Dealing with YAML with arbitrary tags in Python

... in which we use PyYAML to safely read and write YAML with any tags, in a way that's as straightforward as interacting with built-in types.

reader 2.5 released – usage statistics

Hi there! I'm happy to announce version 2.5 of reader , a Python feed reader library. What's new? # Here are the most important changes since reader 2.0 . Search enabled by default # Full-text search works out of the box: no extra dependencies, no setup needed. Statistics # There are now statistics on feed and user activity, to give you a better understanding of how you consume content. First, you…

Write an SQL query builder in 150 lines of Python!

This is the fourth article in a series about writing my own SQL query builder. Today, we'll rewrite it from scratch, explore API design, learn when to be lazy, and look at worse and better ways of doing things – all in 150 lines of Python!

namedtuple in a post-dataclasses world

namedtuple has been around since forever, and over time, its convenience saw it used far outside its originally intended purpose. With dataclasses now covering part of those use cases, what should one use named tuples for? In this article, I address this question, and give a few examples from real code.

reader 2.0 released

Hi there! I'm happy to announce version 2.0 of reader , a Python feed reader library. This release brings you a cleaner API, more consistently named methods and attributes, timezone-aware datetimes, and safer defaults. See the changelog for details. What is reader? # reader takes care of the core functionality required by a feed reader, so you can focus on what makes yours different. reader allows…

Why I wrote my own SQL query builder (in Python)

This is the third article in a series about writing an SQL query builder in 150 lines of Python. Here, I talk about why I decided to write my own, the alternatives I considered, why I didn't use an existing library, and how I knew it wouldn't become a maintenance burden.

When your functions take the same arguments, consider using a class: counter-examples

In this article, we look at a few real-world examples where functions taking the same arguments don't necessarily make a class, as counter-examples to a heuristic for using classes in Python.

Python sentinel objects, type hints, and PEP 661

PEP 661 proposes adding a utility for defining sentinel values in the Python standard library. In this article, you'll get a PEP 661 summary, learn what sentinel objects are (with real-world examples), how to use them with type hints, and a bit about why PEPs exist in the first place.

When to use classes in Python? When your functions take the same arguments

In this article, we look at a heuristic for using classes in Python, with examples from real-world code, and some things to keep in mind.

Why use an SQL query builder in the first place?

This is the second article in a series about writing an SQL query builder in 150 lines of Python, why I wrote it, how I thought about it, and the decisions I had to make. In this article, I talk about why I needed a query builder in the first place, with examples derived from real use cases I had for my feed reader library.

SQL query builder in 150 lines of Python

In this series, we examine an SQL query builder I wrote in 150 lines of Python, why I wrote it, how I thought about it, and the decisions I had to make. This article is a sneak peek of the series and the code.

Using a Makefile with .PHONY-only targets? Use a run.sh script instead

... in which we look at an interesting alternative to Makefiles with .PHONY-only targets, and why I think it's cool.

hashlib: object supporting the buffer API required

In this article, you'll find out what Python hashlib "object supporting the buffer API required" TypeErrors mean, why do they happen, and what you can do about it.

Learn by reading code: Python standard library design decisions explained

On your Python learning journey, you may have heard that a great way to get better is to read code written by other people. That's true, but finding good code to study is not easy, mostly because the design philosophy and the reasoning behind the code are rarely documented. The Python standard library is special in this regard: not only is the code open source, but the discussions around the…

Dataclasses without type annotations

... in which we talk about the many ways of using Python dataclasses without type annotations (or even variable annotations!), and what this says about Python.