[Python-Dev] PEP 557: Data Classes

Mike Miller python-ideas at mgmiller.net
Fri Sep 8 18:17:29 EDT 2017

On 2017-09-08 07:57, Eric V. Smith wrote:
> I've written a PEP for…

Apologies for the following list dumb questions and bikesheds:

- 'Classes can be thought of as "mutable namedtuples with defaults".'

   - A C/C++ (struct)ure sounds like a simpler description that many more
     would understand.

- dataclass name:

     - class, redundant
     - data, good but very common
     - struct, used?
     - Record?  (best I could come up with)

- Source needs blanks between functions, hard to read.

- Are types required?

   Maybe an example or two with Any?

- Intro discounts inheritance and metaclasses as "potentially interfering",
   but unclear why that would be the case.
   Inheritance is easy to override, metaclasses not sure?

- Perhaps mention ORMs/metaclass approach, as prior art:


- Perhaps mention Kivy Properties, as prior art:


- For mutable default values:

   class C:
       x: list  # = field(default_factory=list)

   Could it detect list as a mutable class "type" and set it as a factory

   The PEP/bug #3 mentions using copy, but that's not exactly what I'm asking

More information about the Python-Dev mailing list