Skip to content

Commit

Permalink
Use deep copy.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Jan 6, 2023
1 parent 6d6bf3c commit 626abaa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions science/frozendict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2023 Science project contributors.
# Licensed under the Apache License, Version 2.0 (see LICENSE).

import copy
from typing import Generic, Iterator, Mapping, TypeVar

K = TypeVar("K")
Expand All @@ -10,7 +10,7 @@
class FrozenDict(Generic[K, V], Mapping[K, V]):
def __init__(self, data: Mapping[K, V] | None = None) -> None:
super().__init__()
self._data: Mapping[K, V] = dict(data) if data else {}
self._data: Mapping[K, V] = copy.deepcopy(data) if data else {}
self._hash: int | None = None

def __getitem__(self, key: K) -> V:
Expand Down

0 comments on commit 626abaa

Please sign in to comment.