py3: introduce pycompat.ziplist as zip is a generator on Python 3
authorPulkit Goyal <7895pulkit@gmail.com>
Mon, 11 Dec 2017 05:56:35 +0530
changeset 35405 e66d6e938d2d
parent 35404 6ebe899b6551
child 35406 76dcdc4e707b
py3: introduce pycompat.ziplist as zip is a generator on Python 3 Similar to map, the return value of zip was also turned into a generator on Python 3. We have multiple occurences in our codebase where we retrieve the values of zip multiple times, so let's introduce pycompat.ziplist similar to pycompat.maplist. Differential Revision: https://phab.mercurial-scm.org/D1675
mercurial/pycompat.py
--- a/mercurial/pycompat.py	Mon Dec 11 05:26:46 2017 +0530
+++ b/mercurial/pycompat.py	Mon Dec 11 05:56:35 2017 +0530
@@ -63,6 +63,7 @@
         sysexecutable = os.fsencode(sysexecutable)
     stringio = io.BytesIO
     maplist = lambda *args: list(map(*args))
+    ziplist = lambda *args: list(zip(*args))
     rawinput = input
 
     # TODO: .buffer might not exist if std streams were replaced; we'll need
@@ -313,6 +314,7 @@
     shlexsplit = shlex.split
     stringio = cStringIO.StringIO
     maplist = map
+    ziplist = zip
     rawinput = raw_input
 
 isjython = sysplatform.startswith('java')