[Python-ideas] Possible PEP 380 tweak

Ron Adam rrr at ronadam.com
Mon Oct 25 22:08:06 CEST 2010


Minor correction...

On 10/25/2010 02:53 PM, Ron Adam wrote:


> @consumer
> def reduce_collector(func):
>     try:
>         value = yield            # No value to yield here.
>         while True:
>             value = func((yield), value)        # or here.
>     except YieldError:
>         # next was called not send.
>         yield = value

This line should have been "yield value" not "yield = value".


> def parallel_reduce(iterable, funcs):
>     collectors = [reduce_collector(func) for func in funcs]
>     for v in iterable:
>         for coll in collectors:
>             coll.send(v)
>     return [next(c) for c in collectors]




More information about the Python-ideas mailing list