From bafbcb34caefa7c316fc4e81d2b63a5d42f03ce7 Mon Sep 17 00:00:00 2001 From: Marco Sulla Date: Sun, 6 Oct 2024 15:58:12 +0200 Subject: [PATCH] improved speed of set, setdefault and delete in pure py impl for hashable frozendict --- src/frozendict/_frozendict_py.py | 6 +++--- src/frozendict/version.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/frozendict/_frozendict_py.py b/src/frozendict/_frozendict_py.py index cd81300..ddae55b 100644 --- a/src/frozendict/_frozendict_py.py +++ b/src/frozendict/_frozendict_py.py @@ -159,7 +159,7 @@ def __reduce__(self, *args, **kwargs): return (self.__class__, (dict(self),)) def set(self, key, val): - new_self = deepcopy(dict(self)) + new_self = dict(deepcopy(self)) new_self[key] = val return self.__class__(new_self) @@ -168,14 +168,14 @@ def setdefault(self, key, default=None): if key in self: return self - new_self = deepcopy(dict(self)) + new_self = dict(deepcopy(self)) new_self[key] = default return self.__class__(new_self) def delete(self, key): - new_self = deepcopy(dict(self)) + new_self = dict(deepcopy(self)) del new_self[key] if new_self: diff --git a/src/frozendict/version.py b/src/frozendict/version.py index ddae58b..f8e8f86 100644 --- a/src/frozendict/version.py +++ b/src/frozendict/version.py @@ -1 +1 @@ -version = "2.4.4" +version = "2.4.5"