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

[perf] Increase test performance by 274% with this one weird trick... #1152

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/hdmf/spec/spec.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -102,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
Expand Down Expand Up @@ -149,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()
Expand Down