Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
819581b8
Commit
819581b8
authored
May 28, 2016
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 25926: Clarify that the pure python equivalents are only approximate.
parent
fe289c0f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
19 deletions
+22
-19
Doc/library/itertools.rst
Doc/library/itertools.rst
+21
-19
Misc/ACKS
Misc/ACKS
+1
-0
No files found.
Doc/library/itertools.rst
View file @
819581b8
...
...
@@ -97,7 +97,7 @@ loops that truncate the stream.
:class:`~fractions.Fraction`.) If the input iterable is empty, the
output iterable will also be empty.
E
quivalent to::
Roughly e
quivalent to::
def accumulate(iterable, func=operator.add):
'Return running totals'
...
...
@@ -156,7 +156,7 @@ loops that truncate the stream.
Make an iterator that returns elements from the first iterable until it is
exhausted, then proceeds to the next iterable, until all of the iterables are
exhausted. Used for treating consecutive sequences as a single sequence.
E
quivalent to::
Roughly e
quivalent to::
def chain(*iterables):
# chain('ABC', 'DEF') --> A B C D E F
...
...
@@ -189,7 +189,7 @@ loops that truncate the stream.
value. So if the input elements are unique, there will be no repeat
values in each combination.
E
quivalent to::
Roughly e
quivalent to::
def combinations(iterable, r):
# combinations('ABCD', 2) --> AB AC AD BC BD CD
...
...
@@ -238,7 +238,7 @@ loops that truncate the stream.
value. So if the input elements are unique, the generated combinations
will also be unique.
E
quivalent to::
Roughly e
quivalent to::
def combinations_with_replacement(iterable, r):
# combinations_with_replacement('ABC', 2) --> AA AB AC BB BC CC
...
...
@@ -278,7 +278,7 @@ loops that truncate the stream.
Make an iterator that filters elements from *data* returning only those that
have a corresponding element in *selectors* that evaluates to ``True``.
Stops when either the *data* or *selectors* iterables has been exhausted.
E
quivalent to::
Roughly e
quivalent to::
def compress(data, selectors):
# compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F
...
...
@@ -291,7 +291,7 @@ loops that truncate the stream.
Make an iterator that returns evenly spaced values starting with number *start*. Often
used as an argument to :func:`map` to generate consecutive data points.
Also, used with :func:`zip` to add sequence numbers.
E
quivalent to::
Also, used with :func:`zip` to add sequence numbers.
Roughly e
quivalent to::
def count(start=0, step=1):
# count(10) --> 10 11 12 13 14 ...
...
...
@@ -312,7 +312,7 @@ loops that truncate the stream.
Make an iterator returning elements from the iterable and saving a copy of each.
When the iterable is exhausted, return elements from the saved copy. Repeats
indefinitely.
E
quivalent to::
indefinitely.
Roughly e
quivalent to::
def cycle(iterable):
# cycle('ABCD') --> A B C D A B C D A B C D ...
...
...
@@ -333,7 +333,7 @@ loops that truncate the stream.
Make an iterator that drops elements from the iterable as long as the predicate
is true; afterwards, returns every element. Note, the iterator does not produce
*any* output until the predicate first becomes false, so it may have a lengthy
start-up time.
E
quivalent to::
start-up time.
Roughly e
quivalent to::
def dropwhile(predicate, iterable):
# dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1
...
...
@@ -349,7 +349,7 @@ loops that truncate the stream.
Make an iterator that filters elements from iterable returning only those for
which the predicate is ``False``. If *predicate* is ``None``, return the items
that are false.
E
quivalent to::
that are false.
Roughly e
quivalent to::
def filterfalse(predicate, iterable):
# filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8
...
...
@@ -386,7 +386,7 @@ loops that truncate the stream.
groups.append(list(g)) # Store group iterator as a list
uniquekeys.append(k)
:func:`groupby` is equivalent to::
:func:`groupby` is
roughly
equivalent to::
class groupby:
# [k for k, g in groupby('AAAABBBCCDAABBB')] --> A B C D A B
...
...
@@ -426,7 +426,7 @@ loops that truncate the stream.
specified position. Unlike regular slicing, :func:`islice` does not support
negative values for *start*, *stop*, or *step*. Can be used to extract related
fields from data where the internal structure has been flattened (for example, a
multi-line report may list a name field on every third line).
E
quivalent to::
multi-line report may list a name field on every third line).
Roughly e
quivalent to::
def islice(iterable, *args):
# islice('ABCDEFG', 2) --> A B
...
...
@@ -464,7 +464,7 @@ loops that truncate the stream.
value. So if the input elements are unique, there will be no repeat
values in each permutation.
E
quivalent to::
Roughly e
quivalent to::
def permutations(iterable, r=None):
# permutations('ABCD', 2) --> AB AC AD BA BC BD CA CB CD DA DB DC
...
...
@@ -510,7 +510,7 @@ loops that truncate the stream.
Cartesian product of input iterables.
E
quivalent to nested for-loops in a generator expression. For example,
Roughly e
quivalent to nested for-loops in a generator expression. For example,
``product(A, B)`` returns the same as ``((x,y) for x in A for y in B)``.
The nested loops cycle like an odometer with the rightmost element advancing
...
...
@@ -522,7 +522,7 @@ loops that truncate the stream.
repetitions with the optional *repeat* keyword argument. For example,
``product(A, repeat=4)`` means the same as ``product(A, A, A, A)``.
This function is equivalent to the following code, except that the
This function is
roughly
equivalent to the following code, except that the
actual implementation does not build up intermediate results in memory::
def product(*args, repeat=1):
...
...
@@ -541,7 +541,9 @@ loops that truncate the stream.
Make an iterator that returns *object* over and over again. Runs indefinitely
unless the *times* argument is specified. Used as argument to :func:`map` for
invariant parameters to the called function. Also used with :func:`zip` to
create an invariant part of a tuple record. Equivalent to::
create an invariant part of a tuple record.
Roughly equivalent to::
def repeat(object, times=None):
# repeat(10, 3) --> 10 10 10
...
...
@@ -564,7 +566,7 @@ loops that truncate the stream.
the iterable. Used instead of :func:`map` when argument parameters are already
grouped in tuples from a single iterable (the data has been "pre-zipped"). The
difference between :func:`map` and :func:`starmap` parallels the distinction
between ``function(a,b)`` and ``function(*c)``.
E
quivalent to::
between ``function(a,b)`` and ``function(*c)``.
Roughly e
quivalent to::
def starmap(function, iterable):
# starmap(pow, [(2,5), (3,2), (10,3)]) --> 32 9 1000
...
...
@@ -575,7 +577,7 @@ loops that truncate the stream.
.. function:: takewhile(predicate, iterable)
Make an iterator that returns elements from the iterable as long as the
predicate is true.
E
quivalent to::
predicate is true.
Roughly e
quivalent to::
def takewhile(predicate, iterable):
# takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4
...
...
@@ -588,7 +590,7 @@ loops that truncate the stream.
.. function:: tee(iterable, n=2)
Return *n* independent iterators from a single iterable.
E
quivalent to::
Return *n* independent iterators from a single iterable.
Roughly e
quivalent to::
def tee(iterable, n=2):
it = iter(iterable)
...
...
@@ -619,7 +621,7 @@ loops that truncate the stream.
Make an iterator that aggregates elements from each of the iterables. If the
iterables are of uneven length, missing values are filled-in with *fillvalue*.
Iteration continues until the longest iterable is exhausted.
E
quivalent to::
Iteration continues until the longest iterable is exhausted.
Roughly e
quivalent to::
class ZipExhausted(Exception):
pass
...
...
Misc/ACKS
View file @
819581b8
...
...
@@ -1303,6 +1303,7 @@ Ralf Schmitt
Michael Schneider
Peter Schneider-Kamp
Arvin Schnell
Nofar Schnider
Scott Schram
Robin Schreiber
Chad J. Schroeder
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment