Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Initialise mutable fields of dataclasses safely for reuse #697

Merged
merged 1 commit into from
Sep 11, 2023

Conversation

nolar
Copy link
Contributor

@nolar nolar commented Sep 11, 2023

Otherwise, if the differs are reused multiple times within the same process, there is a risk of leaking accumulated data from the previous runs into the following runs.

In some cases, it can be "solved" by re-initializing these fields explicitly before data accumulation (e.g. self.fld = {...}), or by overwriting the same dict keys on every run — but neither of these is reliable. The field's content must be strictly coupled to the containing object and its lifetime and also disposed of when the object is disposed of.

@nolar nolar requested a review from dlawin September 11, 2023 14:53
@dlawin dlawin merged commit 4ef9cb1 into datafold:master Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants