Skip to content

Commit

Permalink
Simplify RedisDict._populate() (#570)
Browse files Browse the repository at this point in the history
  • Loading branch information
brainix committed Dec 29, 2021
1 parent e2964ae commit 906cac2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pottery/dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,11 @@ def _populate(self,
with contextlib.suppress(AttributeError):
arg = cast(InitMap, arg).items()
items = itertools.chain(cast(InitIter, arg), kwargs.items())

encoded_dict = {}
for key, value in items:
encoded_key = self._encode(key)
encoded_value = self._encode(value)
encoded_dict[encoded_key] = encoded_value

dict_ = dict(items)
encoded_dict = {
self._encode(key): self._encode(value)
for key, value in dict_.items()
}
if encoded_dict:
pipeline.multi()
pipeline.hset(self.key, mapping=encoded_dict) # type: ignore
Expand Down

0 comments on commit 906cac2

Please sign in to comment.