diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2017-11-02 06:30:07 -0700 |
---|---|---|
committer | Jon Dufresne <jon.dufresne@gmail.com> | 2018-11-03 03:21:49 -0700 |
commit | d05afabcc038764d4edfe5040c4ce783da691724 (patch) | |
tree | 9ab1bc81249b8d7ed267e9b149cafe566bad7df7 | |
parent | ac5611c0549942f16e4261ca9895e67832bd7285 (diff) | |
download | redis-py-d05afabcc038764d4edfe5040c4ce783da691724.tar.gz |
Pass generators to dict() instead of coercing to a list
-rwxr-xr-x | redis/client.py | 10 | ||||
-rw-r--r-- | redis/sentinel.py | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/redis/client.py b/redis/client.py index 5b69cec..3787be4 100755 --- a/redis/client.py +++ b/redis/client.py @@ -70,7 +70,7 @@ def parse_debug_object(response): # prefixed with a name response = nativestr(response) response = 'type:' + response - response = dict([kv.split(':') for kv in response.split()]) + response = dict(kv.split(':') for kv in response.split()) # parse some expected int values from the string response # note: this cmd isn't spec'd so these may not appear in all redis versions @@ -303,7 +303,7 @@ def parse_client_list(response, **options): clients = [] for c in nativestr(response).splitlines(): # Values might contain '=' - clients.append(dict([pair.split('=', 1) for pair in c.split(' ')])) + clients.append(dict(pair.split('=', 1) for pair in c.split(' '))) return clients @@ -339,7 +339,7 @@ def parse_slowlog_get(response, **options): def parse_cluster_info(response, **options): - return dict([line.split(':') for line in response.splitlines() if line]) + return dict(line.split(':') for line in response.splitlines() if line) def _parse_node_line(line): @@ -364,7 +364,7 @@ def parse_cluster_nodes(response, **options): raw_lines = response if isinstance(response, basestring): raw_lines = response.splitlines() - return dict([_parse_node_line(line) for line in raw_lines]) + return dict(_parse_node_line(line) for line in raw_lines) def parse_georadius_generic(response, **options): @@ -2901,7 +2901,7 @@ class PubSub(object): """ encode = self.encoder.encode decode = self.encoder.decode - return dict([(decode(encode(k)), v) for k, v in iteritems(data)]) + return dict((decode(encode(k)), v) for k, v in iteritems(data)) def psubscribe(self, *args, **kwargs): """ diff --git a/redis/sentinel.py b/redis/sentinel.py index 518fec5..c4ff892 100644 --- a/redis/sentinel.py +++ b/redis/sentinel.py @@ -171,10 +171,10 @@ class Sentinel(object): # if sentinel_kwargs isn't defined, use the socket_* options from # connection_kwargs if sentinel_kwargs is None: - sentinel_kwargs = dict([(k, v) + sentinel_kwargs = dict((k, v) for k, v in iteritems(connection_kwargs) if k.startswith('socket_') - ]) + ) self.sentinel_kwargs = sentinel_kwargs self.sentinels = [StrictRedis(hostname, port, **self.sentinel_kwargs) |