I think you are getting a bit tangled up in the distinction between what I call "data" and "code":

dicts are data
dataclasses are code.

Granted, in Python this line can be blurry, but I think it's helpful to think about it that way.

Thinking of it this way,  dataclasses.asdict() is converting code to data, and so it makes sense to convert it completely to data. In many contexts where you want a dict, a custom dataclass (or anything other custom class) as values wouldn't really make sense (imagine passing it into the json lib, for instance).

All that being said, an option to do a "shallow" or "deep" conversion in asdict() makes sense to me.


Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython