| 1 | |
| 2 | from pypy.interpreter.mixedmodule import MixedModule |
| 3 | |
| 4 | class Module(MixedModule): |
| 5 | """Functional tools for creating and using iterators. |
| 6 | |
| 7 | Infinite iterators: |
| 8 | count([n]) --> n, n+1, n+2, ... |
| 9 | cycle(p) --> p0, p1, ... plast, p0, p1, ... |
| 10 | repeat(elem [,n]) --> elem, elem, elem, ... endlessly or up to n times |
| 11 | |
| 12 | Iterators terminating on the shortest input sequence: |
| 13 | ifilter(pred, seq) --> elements of seq where pred(elem) is True |
| 14 | ifilterfalse(pred, seq) --> elements of seq where pred(elem) is False |
| 15 | islice(seq, [start,] stop [, step]) --> elements from |
| 16 | seq[start:stop:step] |
| 17 | starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ... |
| 18 | tee(it, n=2) --> (it1, it2 , ... itn) splits one iterator into n |
| 19 | chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ... |
| 20 | takewhile(pred, seq) --> seq[0], seq[1], until pred fails |
| 21 | dropwhile(pred, seq) --> seq[n], seq[n+1], starting when pred fails |
| 22 | groupby(iterable[, keyfunc]) --> sub-iterators grouped by value of keyfunc(v) |
| 23 | izip(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ... |
| 24 | izip_longest(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ... |
| 25 | |
| 26 | Combinatoric generators: |
| 27 | product(p, q, ... [repeat=1]) --> cartesian product |
| 28 | permutations(p[, r]) |
| 29 | combinations(p, r) |
| 30 | combinations_with_replacement(p, r) |
| 31 | """ |
| 32 | |
| 33 | interpleveldefs = { |
| 34 | 'accumulate' : 'interp_itertools.W_Accumulate', |
| 35 | 'chain' : 'interp_itertools.W_Chain', |
| 36 | 'combinations' : 'interp_itertools.W_Combinations', |
| 37 | 'combinations_with_replacement' : 'interp_itertools.W_CombinationsWithReplacement', |
| 38 | 'compress' : 'interp_itertools.W_Compress', |
| 39 | 'count' : 'interp_itertools.W_Count', |
| 40 | 'cycle' : 'interp_itertools.W_Cycle', |
| 41 | 'dropwhile' : 'interp_itertools.W_DropWhile', |
| 42 | 'groupby' : 'interp_itertools.W_GroupBy', |
| 43 | '_groupby' : 'interp_itertools.W_GroupByIterator', |
| 44 | 'filterfalse' : 'interp_itertools.W_FilterFalse', |
| 45 | 'islice' : 'interp_itertools.W_ISlice', |
| 46 | 'pairwise' : 'interp_itertools.W_Pairwise', |
| 47 | 'permutations' : 'interp_itertools.W_Permutations', |
| 48 | 'product' : 'interp_itertools.W_Product', |
| 49 | 'repeat' : 'interp_itertools.W_Repeat', |
| 50 | 'starmap' : 'interp_itertools.W_StarMap', |
| 51 | 'takewhile' : 'interp_itertools.W_TakeWhile', |
| 52 | 'tee' : 'interp_itertools.tee', |
| 53 | '_tee' : 'interp_itertools.W_TeeIterable', |
| 54 | '_tee_dataobject' : 'interp_itertools.W_TeeChainedListNode', |
| 55 | 'zip_longest' : 'interp_itertools.W_ZipLongest', |
| 56 | |
| 57 | } |
| 58 | |
| 59 | appleveldefs = { |
| 60 | } |