diff options
author | andy <andy@whiskeymedia.com> | 2013-05-23 10:35:45 -0400 |
---|---|---|
committer | andy <andy@whiskeymedia.com> | 2013-05-23 10:35:45 -0400 |
commit | b51f22d5b72d33eea4026a4cb0a283d639d8c451 (patch) | |
tree | 4e0529014397e1f986421cad5d5ec733881340a7 /redis/_compat.py | |
parent | b5214ab814b6c35aa8f880ef61c0719b851e60e0 (diff) | |
download | redis-py-b51f22d5b72d33eea4026a4cb0a283d639d8c451.tar.gz |
use iterators for dict traversal in both python 2 and 3
Diffstat (limited to 'redis/_compat.py')
-rw-r--r-- | redis/_compat.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/redis/_compat.py b/redis/_compat.py index 9d59742..564ade7 100644 --- a/redis/_compat.py +++ b/redis/_compat.py @@ -12,8 +12,8 @@ if sys.version_info[0] < 3: from StringIO import StringIO as BytesIO iteritems = lambda x: x.iteritems() - dictkeys = lambda x: x.keys() - dictvalues = lambda x: x.values() + iterkeys = lambda x: x.iterkeys() + itervalues = lambda x: x.itervalues() nativestr = lambda x: \ x if isinstance(x, str) else x.encode('utf-8', 'replace') u = lambda x: x.decode() @@ -31,9 +31,9 @@ else: from io import BytesIO from string import ascii_letters - iteritems = lambda x: x.items() - dictkeys = lambda x: list(x.keys()) - dictvalues = lambda x: list(x.values()) + iteritems = lambda x: iter(x.items()) + iterkeys = lambda x: iter(x.keys()) + itervalues = lambda x: iter(x.values()) byte_to_chr = lambda x: chr(x) nativestr = lambda x: \ x if isinstance(x, str) else x.decode('utf-8', 'replace') |