diff options
author | Guillaume Viot <guillaume.gvt@gmail.com> | 2013-08-21 14:27:54 +0200 |
---|---|---|
committer | Guillaume Viot <guillaume.gvt@gmail.com> | 2013-08-21 14:27:54 +0200 |
commit | a78d50989be9db47992985fbe42f01d99fa25027 (patch) | |
tree | 818d6227b9ca421abd2cdf2d4efeab73d80b6982 /redis/connection.py | |
parent | 94ab83e27c77e0e8ca160e71a491ed9836aec608 (diff) | |
download | redis-py-a78d50989be9db47992985fbe42f01d99fa25027.tar.gz |
Changed the way commands are packed to increase performance
Diffstat (limited to 'redis/connection.py')
-rw-r--r-- | redis/connection.py | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/redis/connection.py b/redis/connection.py index 3a7ca81..2c88b2b 100644 --- a/redis/connection.py +++ b/redis/connection.py @@ -329,17 +329,11 @@ class Connection(object): def pack_command(self, *args): "Pack a series of arguments into a value Redis command" - output = BytesIO() - output.write(SYM_STAR) - output.write(b(str(len(args)))) - output.write(SYM_CRLF) - for enc_value in imap(self.encode, args): - output.write(SYM_DOLLAR) - output.write(b(str(len(enc_value)))) - output.write(SYM_CRLF) - output.write(enc_value) - output.write(SYM_CRLF) - return output.getvalue() + args_output = "".join( + ["%s%s%s%s%s" % (SYM_DOLLAR, len(k), SYM_CRLF, k, SYM_CRLF) for k in imap(self.encode, args)] + ) + output = "%s%s%s%s" % (SYM_STAR, len(args), SYM_CRLF, args_output) + return output class UnixDomainSocketConnection(Connection): |