Skip to content

Ineffective creatiion of arguments for mset, msetnx, hmset #59

@Suor

Description

@Suor
diff --git a/redis/client.py b/redis/client.py
index 41a9660..bbec57a 100644
--- a/redis/client.py
+++ b/redis/client.py
@@ -578,18 +578,14 @@ class Redis(threading.local):

    def mset(self, mapping):
        "Sets each key in the ``mapping`` dict to its corresponding value"
-        items = []
-        [items.extend(pair) for pair in mapping.iteritems()]
-        return self.execute_command('MSET', *items)
+        return self.execute_command('MSET', *mapping.items())

    def msetnx(self, mapping):
        """
        Sets each key in the ``mapping`` dict to its corresponding value if
        none of the keys are already set
        """
-        items = []
-        [items.extend(pair) for pair in mapping.iteritems()]
-        return self.execute_command('MSETNX', *items)
+        return self.execute_command('MSETNX', *mapping.items())

    def move(self, name, db):
        "Moves the key ``name`` to a different Redis database ``db``"
@@ -1132,9 +1128,7 @@ class Redis(threading.local):
        Sets each key in the ``mapping`` dict to its corresponding value
        in the hash ``name``
        """
-        items = []
-        [items.extend(pair) for pair in mapping.iteritems()]
-        return self.execute_command('HMSET', name, *items)
+        return self.execute_command('HMSET', name, *mapping.items())

    def hmget(self, name, keys):
        "Returns a list of values ordered identically to ``keys``"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions