[PATCH py3] ui: construct _keepalnum list in a python3-friendly way

Martijn Pieters mj at zopatista.com
Sat Feb 18 17:58:10 EST 2017


On 16 Feb 2017, at 16:35, Augie Fackler <raf at durin42.com <mailto:raf at durin42.com>> wrote:
> +if pycompat.ispy3:
> +    _unicodes = [bytes([c]).decode('latin1') for c in range(256)]
> +    _notalnum = [s.encode('latin1') for s in _unicodes if not s.isalnum()]

...
> +_keepalnum = ''.join(_notalnum)

This could be more cheaply calculated as

    _keepalnum = bytes(c for c in range(256) if not chr(c).isalnum())

This takes a third of the time.

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


More information about the Mercurial-devel mailing list