[PATCH] util: use string.hexdigits instead of defining it ourselves
Martijn Pieters
mj at zopatista.com
Fri Oct 7 09:31:15 EDT 2016
On 7 October 2016 at 15:14, Augie Fackler <raf at durin42.com> wrote:
> Yeah. I went with this because it seems silly to have our own version of
> the constant when Python already has one that is the right type.
>
There is more silliness.
The whole unquote function duplicates the one in the Python stdlib, from
2.4 somewhere, because it improved perf to not have to import urllib,
see c285bdb0572a48a34c9669a549793e60b5a469d4:
util.url: copy urllib.unquote() into util to improve startup times
However, Python has since moved this function to urlparse in 2.6 (much
smaller module, so no perf reason anymore), the hex-digits dictionary is
build lazily in Python 3, and *most importantly*, those versions avoid the
quadratic performance behaviour of the 2.4 version we copied into Mercurial
(string building with += that evades the CPython optimisation for string
concatenation because multiple strings are being concatenated in each
expression).
So what *really* needs to happen is splitting out the `url` class out to a
new module (so it is used from fewer places and not always imported) and
then the stdlib unquote should be used again.
I'll see about creating a patch for this.
--
Martijn Pieters
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20161007/4c877068/attachment.html>
More information about the Mercurial-devel
mailing list