[PATCH 2 of 2 V2] py3: make py3 compat.iterbytestr simpler and faster
Martin von Zweigbergk
martinvonz at google.com
Wed Mar 15 13:33:12 EDT 2017
# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1489595538 25200
# Wed Mar 15 09:32:18 2017 -0700
# Node ID 74e92020e65e4014ac880542e8a03714810bcde8
# Parent db74b2599efc1997b0e7e6bb7b699717029c11d8
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 -r db74b2599efc -r 74e92020e65e mercurial/pycompat.py
--- a/mercurial/pycompat.py Wed Mar 15 09:30:50 2017 -0700
+++ b/mercurial/pycompat.py Wed Mar 15 09:32:18 2017 -0700
@@ -78,7 +78,7 @@
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
More information about the Mercurial-devel
mailing list