From 3bf8758bbf867adf4ac26814935c2c021b42c3a1 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Tue, 16 Jul 2024 14:55:28 -0700 Subject: [PATCH 1/2] remove deepcopy --- src/hdmf/spec/spec.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hdmf/spec/spec.py b/src/hdmf/spec/spec.py index 358cc3256..d0f463760 100644 --- a/src/hdmf/spec/spec.py +++ b/src/hdmf/spec/spec.py @@ -1,7 +1,6 @@ import re from abc import ABCMeta from collections import OrderedDict -from copy import deepcopy from warnings import warn from ..utils import docval, getargs, popargs, get_docval @@ -84,7 +83,7 @@ class ConstructableDict(dict, metaclass=ABCMeta): def build_const_args(cls, spec_dict): ''' Build constructor arguments for this ConstructableDict class from a dictionary ''' # main use cases are when spec_dict is a ConstructableDict or a spec dict read from a file - return deepcopy(spec_dict) + return spec_dict @classmethod def build_spec(cls, spec_dict): From eae650c9ea5a796a1b35e78d1f3c148d1d33f818 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Tue, 16 Jul 2024 16:08:21 -0700 Subject: [PATCH 2/2] hash function that isn't object identity --- src/hdmf/spec/spec.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hdmf/spec/spec.py b/src/hdmf/spec/spec.py index d0f463760..30d0f0782 100644 --- a/src/hdmf/spec/spec.py +++ b/src/hdmf/spec/spec.py @@ -101,6 +101,8 @@ def build_spec(cls, spec_dict): warn(f'Unexpected keys {unused_vargs} in spec {spec_dict}') return cls(**kwargs) + def __hash__(self): + return hash(str(self)) class Spec(ConstructableDict): ''' A base specification class @@ -148,9 +150,6 @@ def build_const_args(cls, spec_dict): ret = super().build_const_args(spec_dict) return ret - def __hash__(self): - return id(self) - @property def path(self): stack = list()