Sequences, streams, and generators.
|
(object, str)
|
read_pickle(read,
init='',
length_thresh=100000)
Given a reader function read, reads in
pickled objects from it. |
source code
|
|
|
|
read_pickles(read)
Reads all the consecutively pickled objects from the read function. |
source code
|
|
|
|
write_pickle(obj,
write)
Write obj using function write, in a safe, pickle-able fashion. |
source code
|
|
|
|
|
|
|
chunkify(stream,
chunk_size=8192)
Given an input stream (an object exposing a file-like interface),
reads data in from it one chunk at a time. |
source code
|
|
|
int
|
|
|
|
pairwise(iterable)
s -> (s0,s1), (s1,s2), (s2, s3), ... |
source code
|
|
|
|
argmax(sequence,
fn=None)
Two usage patterns: argmax([s0, s1, ...], fn)
argmax([(fn(s0), s0), (fn(s1), s1), ...]) Both return
the si with greatest fn(si) |
source code
|
|
|
|
argmin(sequence,
fn=None)
Two usage patterns: argmin([s0, s1, ...], fn)
argmin([(fn(s0), s0), (fn(s1), s1), ...]) Both return
the si with smallest fn(si) |
source code
|
|
|
|
|
|
|
flatten(stream)
For each item yielded by stream, if that
item is itself an iterator/generator, then I will recurse into
flatten(gen); otherwise, I'll yield the yielded item. |
source code
|
|
|
|
grouper(n,
iterable,
padvalue=None)
grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'),
('g','x','x') |
source code
|
|
|
|
|
|
|
countstep(start,
step)
Generate [start, start+step, start+2*step, start+3*step, ...]. |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
span(pred,
xs)
Returns (successes, failures), where successes is the sequence of any
consecutive elements at the head of xs that
satisfy the predicate, and second is everything else. |
source code
|
|
|
|
group_as_subseqs(xs,
key=<function <lambda> at 0x1d7de60>)
Takes a sequence and breaks it up into multiple subsequences, which
are groups keyed on key. |
source code
|
|