summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-10-12 14:33:17 -0400
committerBenjamin Peterson <benjamin@python.org>2014-10-12 14:33:17 -0400
commit0d77f9165f69e5f46ce364439484157bb193ff11 (patch)
tree490666c8401f33c44a619ce6c3362e6ff1a6ca8c
parentb460b9af7624ee1f3cfdc05e33f1945f04180580 (diff)
downloadsix-0d77f9165f69e5f46ce364439484157bb193ff11.tar.gz
optimize iterbytes on Python 2 (fixes #97)
Suggested by Wouter Bolsterlee.
-rw-r--r--CHANGES2
-rw-r--r--six.py4
2 files changed, 4 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 02a20f0..fa74e77 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,8 @@ This file lists the changes in each six version.
Development version
-------------------
+- Issue #97: Optimize `six.iterbytes` on Python 2.
+
- Issue #98: Fix `six.moves` race condition in multi-threaded code.
- Pull request #51: Add `six.view(keys|values|itmes)`, which provide dictionary
diff --git a/six.py b/six.py
index 0df4538..232a0c7 100644
--- a/six.py
+++ b/six.py
@@ -23,6 +23,7 @@
from __future__ import absolute_import
import functools
+import itertools
import operator
import sys
import types
@@ -621,8 +622,7 @@ else:
return ord(bs[0])
def indexbytes(buf, i):
return ord(buf[i])
- def iterbytes(buf):
- return (ord(byte) for byte in buf)
+ iterbytes = functools.partial(itertools.imap, ord)
import StringIO
StringIO = BytesIO = StringIO.StringIO
_add_doc(b, """Byte literal""")