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

Yuya Nishihara yuya at tcha.org
Sat Mar 11 14:27:57 EST 2017


On Sat, 11 Mar 2017 11:03:40 -0800, Martijn Pieters wrote:
> 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())

Isn't the name resolved before calling map()? That's only reason I restored
the original map() use from fd598149112b.


More information about the Mercurial-devel mailing list