实验内存数据流管道。
tinyflow的Python项目详细描述
数据流编程实验。
经过一些实验,apache beam的python sdk得到了正确的api。 用这个代替。
标准字数示例
在LICENSE.txt
中获取5个最常用的单词fromcollectionsimportCounterfromtinyflow.serialimportops,Pipelinepipe=Pipeline() \ |"Split line into words">>ops.flatmap(lambdax:x.lower().split()) \ |"Remove empty lines">>ops.filter(bool) \ |"Produce the 5 most common words">>ops.counter(5) \ |"Sort by frequency desc">>ops.sort(key=lambdax:x[1],reverse=True)withopen('LICENSE.txt')asf:results=dict(pipe(f))
仅使用python的内置项:
fromcollectionsimportCounterimportitertoolsasitwithopen('LICENSE.txt')asf:lines=(line.lower().split()forlineinf)words=it.chain.from_iterable(lines)count=Counter(words)results=dict(count.most_common(10))
开发
$ git clone https://github.com/geowurster/tinyflow.git $cd tinyflow $ pip install -e .\[all\]$ pytest --cov tinyflow --cov-report term-missing
许可证
见LICENSE.txt
更改日志
见CHANGES.md