Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asdict use deep copy to dataclass instances #88861

Closed
Itayazolay mannequin opened this issue Jul 21, 2021 · 2 comments
Closed

asdict use deep copy to dataclass instances #88861

Itayazolay mannequin opened this issue Jul 21, 2021 · 2 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Itayazolay
Copy link
Mannequin

Itayazolay mannequin commented Jul 21, 2021

BPO 44695
Nosy @ericvsmith, @Itayazolay, @bentheiii, @akulakov
Superseder
  • bpo-43905: dataclasses.astuple (and .asdict) do deepcopy on all fields
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-11-28.19:17:43.451>
    created_at = <Date 2021-07-21.11:29:22.227>
    labels = ['type-bug', '3.8', '3.9', '3.10', '3.11', '3.7', 'library']
    title = 'asdict use deep copy to dataclass instances'
    updated_at = <Date 2021-11-28.19:17:43.448>
    user = 'https://github.com/Itayazolay'

    bugs.python.org fields:

    activity = <Date 2021-11-28.19:17:43.448>
    actor = 'andrei.avk'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-11-28.19:17:43.451>
    closer = 'andrei.avk'
    components = ['Library (Lib)']
    creation = <Date 2021-07-21.11:29:22.227>
    creator = 'Itayazolay'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44695
    keywords = []
    message_count = 2.0
    messages = ['397938', '407220']
    nosy_count = 4.0
    nosy_names = ['eric.smith', 'Itayazolay', 'avrahami.ben', 'andrei.avk']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '43905'
    type = 'behavior'
    url = 'https://bugs.python.org/issue44695'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']

    @Itayazolay
    Copy link
    Mannequin Author

    Itayazolay mannequin commented Jul 21, 2021

    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

    @Itayazolay Itayazolay mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error 3.10 only security fixes 3.11 only security fixes labels Jul 21, 2021
    @akulakov
    Copy link
    Contributor

    Duplicate of https://bugs.python.org/issue43905

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant