I thought I have already asked this. But I do not see it on the
history of the group. Apologize for multiple posting.


Is there an equivalent in Sage to ParallelMap in mathematica?

I am looking a method that applies a given function to a list of
objects for a small presentation of Sage I am preparing.

I am aware of the @parallel decorator. That does exactly what I am
looking for. However, the output of the decorator is a little ugly and
I am looking for something even more transparent to the user.

I am currently using the following function:

sage: def parallel_map(funcion,
list_of_values):
....:     @parallel
....:     def par_funcion(*args, **kwds):
....:         return funcion(*args, **kwds)
....:     output_list = [foo for foo in par_funcion(list_of_values)]
....:     dictionary = {}
....:     for i in
output_list:
....:         dictionary[i[0][0][0]] = i[1]
....:     return [dictionary[i] for i in list_of_values]
....:
sage: K = QQ[x]
sage: L = [K.random_element(450)*K.random_element(450) for i in
range(2)]
sage: r1 = map(factor, L)
sage: r2 = parallel_map(factor, L)
sage: r1 == r2
True


That is just @parallel with some treatment on the output and seems to
work for simple enough functions. This is enough for my presentation,
but, is there anything similar already in Sage?

Thanks,

Luis

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to