Skip to content

Commit

Permalink
Merge pull request #412 from groutr/faster_assoc
Browse files Browse the repository at this point in the history
More efficient assoc
  • Loading branch information
eriknw authored Oct 8, 2018
2 parents 68d8df8 + eb26030 commit 062786a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion toolz/dicttoolz.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ def assoc(d, key, value, factory=dict):
{'x': 1, 'y': 3}
"""
d2 = factory()
d2.update(d)
d2[key] = value
return merge(d, d2, factory=factory)
return d2


def dissoc(d, *keys):
Expand Down

0 comments on commit 062786a

Please sign in to comment.