[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Wish: Parallel Map

From: Joe Python
Subject: [Chicken-users] Wish: Parallel Map
Date: Mon, 27 Dec 2010 19:13:54 -0500

Python has a Parallel version of 'map' where we can  offload work to os level processes (worker pool) and get the results

-------------< cut here >-----------------------
from multiprocessing import Pool

def f(x):
    return x*x

if __name__ == '__main__':
    pool = Pool(processes=4)               # start 4 worker processes
    result = pool.apply_async(f, [10])     # evaluate "f(10)" asynchronously
    print(result.get(timeout=1))           # prints "100" unless your computer is *very* slow
    print(, range(10)))          # prints "[0, 1, 4,..., 81]"
----------------< end >--------------------------

I am aware that Chicken has threads, but they are limited to a single process. An egg for parallel map would be a welcome addition for new schemers like me to make use of those extra cores :)

- Joe

reply via email to

[Prev in Thread] Current Thread [Next in Thread]