diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2019-12-29 16:52:22 -0800 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2019-12-29 16:52:22 -0800 |
commit | 272d3139e1c82c2d89551f87d12df7c18d938ea2 (patch) | |
tree | 297f2dad4fb666d8bf8dedc427b1bc7e335dd303 | |
parent | 9cbb48aaa31752f8d707af9b4ec8c90a48e7f8bb (diff) | |
download | redis-py-272d3139e1c82c2d89551f87d12df7c18d938ea2.tar.gz |
Slight optimization to command packing.
Fixed #1255
-rw-r--r-- | CHANGES | 1 | ||||
-rwxr-xr-x | redis/connection.py | 7 |
2 files changed, 5 insertions, 3 deletions
@@ -18,6 +18,7 @@ connections should require the server hostname to match the hostname specified in the SSL cert. By default 'ssl_check_hostname' is False for backwards compatibility. #1196 + * Slightly optimized command packing. Thanks @Deneby67. #1255 * 3.3.11 * Further fix for the SSLError -> TimeoutError mapping to work on obscure releases of Python 2.7. diff --git a/redis/connection.py b/redis/connection.py index 926f2c7..b27bf21 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -757,15 +757,16 @@ class Connection(object): for arg in imap(self.encoder.encode, args): # to avoid large string mallocs, chunk the command into the # output list if we're sending large values - if len(buff) > buffer_cutoff or len(arg) > buffer_cutoff: + arg_length = len(arg) + if len(buff) > buffer_cutoff or arg_length > buffer_cutoff: buff = SYM_EMPTY.join( - (buff, SYM_DOLLAR, str(len(arg)).encode(), SYM_CRLF)) + (buff, SYM_DOLLAR, str(arg_length).encode(), SYM_CRLF)) output.append(buff) output.append(arg) buff = SYM_CRLF else: buff = SYM_EMPTY.join( - (buff, SYM_DOLLAR, str(len(arg)).encode(), + (buff, SYM_DOLLAR, str(arg_length).encode(), SYM_CRLF, arg, SYM_CRLF)) output.append(buff) return output |