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
c5705a82
Commit
c5705a82
authored
Feb 22, 2008
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document itertools.product().
parent
fb0742fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
Doc/library/itertools.rst
Doc/library/itertools.rst
+23
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/itertools.rst
View file @
c5705a82
...
...
@@ -302,6 +302,29 @@ loops that truncate the stream.
.. versionadded:: 2.6
.. function:: product(*iterables)
Cartesian product of input iterables.
Equivalent 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 leftmost iterators are in the outermost for-loop, so the output tuples
cycle in a manner similar to an odometer (with the rightmost element
changing on every iteration).
Equivalent to (but without building the entire result in memory)::
def product(*args):
pools = map(tuple, args)
if pools:
result = [[]]
for pool in pools:
result = [x+[y] for x in result for y in pool]
for prod in result:
yield tuple(prod)
.. versionadded:: 2.6
.. function:: repeat(object[, times])
...
...
Misc/NEWS
View file @
c5705a82
...
...
@@ -635,6 +635,9 @@ Library
- itertools.count() is no longer bounded to LONG_MAX. Formerly, it raised
an OverflowError. Now, automatically shifts from ints to longs.
- Added itertools.product() which forms the Cartesian product of
the input iterables.
- Patch #1541463: optimize performance of cgi.FieldStorage operations.
- Decimal is fully updated to the latest Decimal Specification (v1.66).
...
...
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