Skip to content

Commit

Permalink
Tweak for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Hall committed Oct 24, 2024
1 parent 56aa644 commit 3fbd62e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 4 additions & 6 deletions gramps/gen/lib/baseobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ def get_object_state(self):
of the object or None if the object is empty.
:rtype: dict
"""
attr_dict = {"_class": self.__class__.__name__}
for key, value in self.__dict__.items():
if not key.startswith("_"):
attr_dict[key] = value
attr_dict = dict((key, value) for key, value in self.__dict__.items()
if not key.startswith("_"))
attr_dict[ "_class"] = self.__class__.__name__
return attr_dict

def set_object_state(self, attr_dict):
Expand All @@ -97,8 +96,7 @@ def set_object_state(self, attr_dict):
:type attr_dict: dict
"""
for key, value in attr_dict.items():
if key != "_class":
setattr(self, key, value)
setattr(self, key, value)

def matches_string(self, pattern, case_sensitive=False):
"""
Expand Down
1 change: 1 addition & 0 deletions gramps/gen/lib/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

def __object_hook(obj_dict):
obj = getattr(lib, obj_dict["_class"])()
del obj_dict["_class"]
obj.set_object_state(obj_dict)
return obj

Expand Down

0 comments on commit 3fbd62e

Please sign in to comment.