# HG changeset patch # User Martin von Zweigbergk # Date 2017-03-15 16:32:18 # Node ID 63a39d64788872a5742f8e3143b7ddd603e3af13 # Parent 4acc49335a6ec891d37f5c6e47e1c2f2078b895c py3: make py3 compat.iterbytestr simpler and faster With Python 3.4.3, timit says 11.9 usec-> 6.44 usec. With Python 3.6.0, timeit says 14.1 usec -> 9.55 usec. diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -78,7 +78,7 @@ if ispy3: def iterbytestr(s): """Iterate bytes as if it were a str object of Python 2""" - return iter(s[i:i + 1] for i in range(len(s))) + return map(bytechr, s) def sysstr(s): """Return a keyword str to be passed to Python functions such as