[PATCH 2 of 3] py3: factor out bytechr() function

Martijn Pieters mj at zopatista.com
Sat Mar 11 14:03:40 EST 2017


On 8 March 2017 at 07:52, Yuya Nishihara <yuya at tcha.org> wrote:

> +_keepalnum = ''.join(c for c in map(pycompat.bytechr, range(256))
> +                     if not c.isalnum())
>

You probably want to make pycompat.bytechr a local name too, to 256
attribute lookups. Also, for `str.join` only, you want to use a list comp
here, not a generator expression, as it is faster and more memory efficient:

_xchar = pycompat.bytechr
_keepalnum = ''.join(c for c in map(_xchar, range(256))
                     if not c.isalnum())

-- 
Martijn Pieters
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170311/ef50a344/attachment.html>


More information about the Mercurial-devel mailing list