Neil Girdhar <mistersh...@gmail.com> added the comment:

> I'm not crazy about adding a method to every dataclass just for the 0.1% of 
> the times it's needed.

I'm not sure I totally understand the cost here.  You can have a single shared 
global function that you set on each dataclass.  So the only cost would be an 
entry in each dataclass type's dict.  Even if a user creates a thousand 
dataclasses, that should only be tens of killobytes in pointers.

> I think using hasattr or catching the exception is a better way to go.

If you choose this, then I think this should be documented under the 
__post_init__ saying that any time you define __post_init__, you should either 
be a final class, or else call super.  If you call super, you musteither use 
hasattr(super().__post_init__) or catch the exception.

I have to admit, I find this quite ugly from a user perspective.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46757>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to