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

Martijn Pieters mj at zopatista.com
Sun Mar 12 12:02:55 EDT 2017


On Sat, 11 Mar 2017 at 11:28, Yuya Nishihara <yuya at tcha.org> wrote:

> 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.


Of course it is please ignore me, I was not thinking and used my list
comprehension reflexes.

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


More information about the Mercurial-devel mailing list