On Mon, 18 Jan 2021 12:41:45 -0800 Chris Barker via Python-Dev email@example.com wrote:
And in "real world" code, I've done just this -- building a system for saving / restoring dataclasses to/from JSON. In that case, each of the dataclasses knows how to save itself and build itself from JSON-compatible python objects (numbers, dicts, strings, lists) -- so again, no need for pattern matching there either. And what I really like about the approach of putting all the logic in the "nodes" is that I can make new types of nodes without having to touch the code at the "top" that visits those nodes.
Note that another approach is the little-used `functools.singledispatch`.