summaryrefslogtreecommitdiff
path: root/redis/client.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2010-08-18 11:34:02 -0700
committerAndy McCurdy <andy@andymccurdy.com>2010-08-18 11:34:02 -0700
commit22379e54a6dd644184f364e568753733b2d864a2 (patch)
tree56dc113f32d5816a79a48a75be3dca95b72e838b /redis/client.py
parentcc614423129e156b38ac0ba789287f60838234df (diff)
downloadredis-py-22379e54a6dd644184f364e568753733b2d864a2.tar.gz
optimized execute_command thanks to github user Suor
Diffstat (limited to 'redis/client.py')
-rw-r--r--redis/client.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/redis/client.py b/redis/client.py
index e6c5cf8..3e22615 100644
--- a/redis/client.py
+++ b/redis/client.py
@@ -4,7 +4,7 @@ import socket
import threading
import time
import warnings
-from itertools import chain
+from itertools import chain, imap
from redis.exceptions import ConnectionError, ResponseError, InvalidResponse
from redis.exceptions import RedisError, AuthenticationError
@@ -319,14 +319,11 @@ class Redis(threading.local):
def execute_command(self, *args, **options):
"Sends the command to the redis server and returns it's response"
- cmd_count = len(args)
- cmds = []
- for i in args:
- enc_value = self.encode(i)
- cmds.append('$%s\r\n%s\r\n' % (len(enc_value), enc_value))
+ cmds = ['$%s\r\n%s\r\n' % (len(enc_value), enc_value)
+ for enc_value in imap(self.encode, args)]
return self._execute_command(
args[0],
- '*%s\r\n%s' % (cmd_count, ''.join(cmds)),
+ '*%s\r\n%s' % (len(cmds), ''.join(cmds)),
**options
)