summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-12-04 23:42:12 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-12-04 23:42:12 (GMT)
commit6e35394ed5f01bd7b06a3366cadaeb8f765851ef (patch)
tree1bc948ae4bd739d65f2ece8d83015222eae6a43d
parent6f04adc54b224eae6be563413ddb995e25c3eb22 (diff)
downloadcpython-6e35394ed5f01bd7b06a3366cadaeb8f765851ef.zip
cpython-6e35394ed5f01bd7b06a3366cadaeb8f765851ef.tar.gz
cpython-6e35394ed5f01bd7b06a3366cadaeb8f765851ef.tar.bz2
Mention itertools.accumulate().
-rw-r--r--Doc/library/random.rst1
-rw-r--r--Doc/whatsnew/3.2.rst19
2 files changed, 19 insertions, 1 deletions
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
index ba369e1..33ab5e5 100644
--- a/Doc/library/random.rst
+++ b/Doc/library/random.rst
@@ -274,6 +274,7 @@ change across Python versions, but two aspects are guaranteed not to change:
* The generator's :meth:`random` method will continue to produce the same
sequence when the compatible seeder is given the same seed.
+.. _random-examples:
Examples and Recipes
====================
diff --git a/Doc/whatsnew/3.2.rst b/Doc/whatsnew/3.2.rst
index 6e1daf9..3c913a1 100644
--- a/Doc/whatsnew/3.2.rst
+++ b/Doc/whatsnew/3.2.rst
@@ -405,7 +405,8 @@ New, Improved, and Deprecated Modules
>>> get_phone_number.cache_clear()
- (Contributed by Raymond Hettinger.)
+ (Contributed by Raymond Hettinger and incorporating design ideas from
+ Jim Baker, Miki Tebeka, and Nick Coglan.)
* The :func:`functools.wraps` decorator now adds a :attr:`__wrapped__` attribute
pointing to the original callable function. This allows wrapped functions to
@@ -416,6 +417,22 @@ New, Improved, and Deprecated Modules
(By Nick Coghlan and Terrence Cole; :issue:`9567`, :issue:`3445`, and
:issue:`8814`.)
+* The :mod:`itertools` module has a new function, :func:`~itertools.accumulate`
+ modeled on APL's *scan* and on Numpy's *accumulate* function:
+
+ >>> list(accumulate(8, 2, 50))
+ [8, 10, 60]
+
+ >>> prob_dist = [0.1, 0.4, 0.2, 0.3]
+ >>> list(accumulate(prob_dist)) # cumulative probability distribution
+ [0.1, 0.5, 0.7, 1.0]
+
+ For an example using :func:`~itertools.accumulate`, see the :ref:`examples for
+ the random module <random-examples>`.
+
+ (Contributed by Raymond Hettinger and incorporating design suggestions
+ from Mark Dickinson.)
+
* The :mod:`nntplib` module gets a revamped implementation with better
bytes / unicode semantics as well as more practical APIs. These improvements
break compatibility with the nntplib version in Python 3.1, which was