Skip to content

Archive

Data Modeling

3 articles
Python 09 Sep 2026 9 min read

Update Immutable Records with Python copy.replace()

I like immutable value objects because they make state changes explicit. The awkward part is that Python has historically offered several different ways to create a slightly modified version of one. A dataclass has dataclasses.replace(). A named tuple has _replace(). A custom class usually needs its own helper. The operations are conceptually similar, but generic code has no single interface to target. Python 3.13 adds copy.replace() to close that gap. It creates a new object of the same type while replacing selected fields, and it works with dataclasses, named tuples, and classes that implement __replace__().

Python 09 Sep 2026 12 min read

Model UUID Sentinels with uuid.NIL and uuid.MAX

UUIDs are often treated as ordinary identifiers: generate one, store it, compare it, and pass it between services. But some systems also need boundary or sentinel UUID values. A protocol may reserve an all-zero identifier for “no object.” A range query may need the lowest or highest possible UUID. Test fixtures may need deterministic endpoints without inventing magic strings. Python 3.14 makes those cases explicit with two constants from RFC 9562:

Python 04 Sep 2026 11 min read

Model Combinable Options in Python with enum.Flag and IntFlag

Some values represent one choice from a fixed set. A log level might be INFO, WARNING, or ERROR. Python’s Enum is a natural fit because one value should identify one member. Other values represent a combination of independent options. A file operation may allow reading and writing. A protocol field may enable compression and encryption. A component may expose several capabilities at the same time. Representing those combinations as ordinary booleans works at first: