This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: asdict use deep copy to dataclass instances
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: dataclasses.astuple (and .asdict) do deepcopy on all fields
View: 43905
Assigned To: Nosy List: Itayazolay, andrei.avk, avrahami.ben, eric.smith
Priority: normal Keywords:

Created on 2021-07-21 11:29 by Itayazolay, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg397938 - (view) Author: Itay azolay (Itayazolay) * Date: 2021-07-21 11:29
Hi, 
I noticed that 'asdict' use 'deepcopy' on all fields of the dataclass recursively. 
I believe this behavior can become optional with an argument, and shouldn't be decided for the user as the deepcopy takes significant amount of cpu and can have unexpected consequences on memory.

I don't mind taking this PR if you agree. 
Thanks
msg407220 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-11-28 19:17
Duplicate of https://bugs.python.org/issue43905
History
Date User Action Args
2022-04-11 14:59:47adminsetgithub: 88861
2021-11-28 19:17:43andrei.avksetstatus: open -> closed

superseder: dataclasses.astuple (and .asdict) do deepcopy on all fields

nosy: + andrei.avk
messages: + msg407220
resolution: duplicate
stage: resolved
2021-07-21 19:09:02Itayazolaysetversions: + Python 3.10, Python 3.11, - Python 3.6
2021-07-21 18:38:42avrahami.bensetnosy: + avrahami.ben
2021-07-21 11:39:14xtreaksetnosy: + eric.smith
2021-07-21 11:29:22Itayazolaycreate