map

>>> def add(x,y):
	return x+y
>>> m = map(add, [1,2,3], [4,5,6])
>>> m
<map object at 0x10da84bd0>
>>> next(m)
5
>>> next(m)
7
>>> next(m)
9
>>> next(m)
StopIteration

zip

filter

>>> f = filter( lambda t : t > 0, [-1, 3, 9, 23, -296,123] )
>>> f
<filter object at 0x10da972d0>
>>> next(f)
3
>>> next(f)
9
>>> next(f)
23
>>> next(f)
123
>>> next(f)
StopIteration

reduce

>>> import functools
>>> def add(x,y):
	print(str(x) + '+' + str(y))
	return x + y

>>> functools.reduce(add, [1,20,300,400])
1+20
21+300
321+400
721

シンプルな並列処理

Pool.map() で 例外が起きたらどうなる

Thread Pool


タイムアウト付きの imap 実行サンプル


Python


添付ファイル: filecpu.png 2231件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2012-10-18 (木) 01:48:39 (4201d)
Short-URL: https://at-sushi.com:443/pukiwiki/index.php?cmd=s&k=38043a1595
ISBN10
ISBN13
9784061426061