Python's match
-case
blocks are complex structural pattern matching tools that are often more hassle than they're worth. But they're great for parsing abstract syntax trees.
Table of contents
Why remove dataclasses?
First let's briefly talk about why I made this tool.
Why would anyone want to convert a dataclass into "not a dataclass"?
There are trade offs with using dataclasses: performance concerns (which don't usually matter) and edge cases where things get weird (__slots__
and slots=True
are both finicky).
But my reason for creating this dataclass to regular class converter was to help me better teach dataclasses.
Seeing the equivalent code for a dataclass helps us appreciate what dataclasses do for us.
Okay let's dive into match
-case
.
Oh, that's what that tool is for?
I knew the adventure I …