[PATCH 3 of 7] pycompat: alias xrange to range in py3

timeless timeless at gmail.com
Sat Apr 9 21:54:16 EDT 2016


mpm suggested this approach.

On Fri, Apr 8, 2016 at 11:28 PM, Gregory Szorc <gregory.szorc at gmail.com> wrote:
>
>
>> 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).
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list