[PATCH 3 of 7] pycompat: alias xrange to range in py3
Gregory Szorc
gregory.szorc at gmail.com
Fri Apr 8 23:28:19 EDT 2016
> On Apr 8, 2016, at 09:22, timeless <timeless at mozdev.org> wrote:
>
> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1459982152 0
> # Wed Apr 06 22:35:52 2016 +0000
> # Node ID cbae00f13ee7afa9dfee577a325ee31d46a84a59
> # Parent 295d79e7d8dd3da8e9ce33611916574d7ddc0ad8
> pycompat: alias xrange to range in py3
>
> diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
> --- a/mercurial/pycompat.py
> +++ b/mercurial/pycompat.py
> @@ -17,3 +17,9 @@
> import queue as _queue
> empty = _queue.Empty
> queue = _queue.Queue
> +
> +try:
> + xrange
> +except NameError:
> + import builtins
> + builtins.xrange = range
I'm really not a fan of mucking around with the standard library. I'd rather we use pycompat.xrange (or similar) everywhere (or at least cases where we need a generator for perf reasons).
More information about the Mercurial-devel
mailing list