]> granicus.if.org Git - python/commitdiff
Issue #12666: Added section about map changes.
authorJason R. Coombs <jaraco@jaraco.com>
Sat, 3 Dec 2011 13:24:21 +0000 (08:24 -0500)
committerJason R. Coombs <jaraco@jaraco.com>
Sat, 3 Dec 2011 13:24:21 +0000 (08:24 -0500)
Doc/howto/pyporting.rst

index 309f3f7a3a74b483a2438ea76fe688deeb3e25b2..df0d299f4a3183d421c23e4b7eabf63d952f45b3 100644 (file)
@@ -505,6 +505,18 @@ Otherwise it might very well be worth your time and effort to port your tests
 to :mod:`unittest`.
 
 
+Update `map` for imbalanced input sequences
+'''''''''''''''''''''''''''''''''''''''''''
+
+With Python 2, `map` would pad input sequences of unequal length with
+`None` values, returning a sequence as long as the longest input sequence.
+
+With Python 3, if the input sequences to `map` are of unequal length, `map`
+will stop at the termination of the shortest of the sequences. For full
+compatibility with `map` from Python 2.x, also wrap the sequences in
+:func:`itertools.zip_longest`, e.g. ``map(func, *sequences)`` becomes
+``list(map(func, itertools.zip_longest(*sequences)))``.
+
 Eliminate ``-3`` Warnings
 -------------------------