Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

A very simple way to use paralelism is provided by the @parallel decorator.

Just write a function that does what you want,with the decorator at the beginning. Then you can pass it a list of entries, and the output will be an iterator with the answers.

Example:

sage: @parallel
....: def f(a):
....:     return a^2
....: 
sage: r=f([1,2,3,4])
sage: r.next()
(((1,), {}), 1)
sage: r.next()
(((2,), {}), 4)
sage: r.next()
(((3,), {}), 9)
sage: r.next()
(((4,), {}), 16)
sage: r.next()
---------------------------------------------------------------------------
StopIteration                             Traceback (most recent call last)