Skip to content

Commit

Permalink
improved speed of set, setdefault and delete in pure py impl for hash…
Browse files Browse the repository at this point in the history
…able frozendict
  • Loading branch information
Marco-Sulla committed Oct 6, 2024
1 parent 5073ca7 commit bafbcb3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/frozendict/_frozendict_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/frozendict/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "2.4.4"
version = "2.4.5"

0 comments on commit bafbcb3

Please sign in to comment.