# HG changeset patch
# User Nathan Carter <ncarter@bentley.edu>
# Date 1326141549 18000
# Node ID 19972bc1910b3a19ad804427d6ea0f2a4b50fb6a
# Parent 3db8e6476c8e0b4302bc9c1808d132b58db6e76e
Improving documentation for @parallel, as requested in ticket 11462.
diff git a/sage/parallel/decorate.py b/sage/parallel/decorate.py
a

b


194  194  ... def f(N): return N^2 
195  195  sage: v = list(f([1,2,4])); v.sort(); v 
196  196  [(((1,), {}), 1), (((2,), {}), 4), (((4,), {}), 16)] 
 197  
 198  For functions that take multiple arguments, enclose the arguments in tuples 
 199  when calling the parallel function:: 
 200  
 201  sage: @parallel 
 202  ... def f(a,b): return a*b 
 203  sage: for X, Y in sorted(list(f([(2,3),(3,5),(5,7)]))): print X, Y 
 204  ((2, 3), {}) 6 
 205  ((3, 5), {}) 15 
 206  ((5, 7), {}) 35 
 207  
 208  For functions that take a single tuple as an argument, enclose it in an 
 209  additional tuple at call time, to distinguish it as the first argument, 
 210  as opposed to a tuple of arguments:: 
 211  
 212  sage: @parallel 
 213  ... def firstEntry(aTuple): return aTuple[0] 
 214  sage: for X, Y in sorted(list(firstEntry([((1,2,3,4),),((5,6,7,8),)]))): print X, Y 
 215  (((1, 2, 3, 4),), {}) 1 
 216  (((5, 6, 7, 8),), {}) 5 
197  217  """ 
198  218  import types 
199  219  if isinstance(p_iter, types.FunctionType): 