diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-10-12 14:33:17 -0400 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-10-12 14:33:17 -0400 |
commit | 0d77f9165f69e5f46ce364439484157bb193ff11 (patch) | |
tree | 490666c8401f33c44a619ce6c3362e6ff1a6ca8c | |
parent | b460b9af7624ee1f3cfdc05e33f1945f04180580 (diff) | |
download | six-0d77f9165f69e5f46ce364439484157bb193ff11.tar.gz |
optimize iterbytes on Python 2 (fixes #97)
Suggested by Wouter Bolsterlee.
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | six.py | 4 |
2 files changed, 4 insertions, 2 deletions
@@ -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 @@ -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""") |