is there a concurrent list for append in parallel programming in python? how to pass parameter in this parallel program with pool?

meInvent bbird jobmattcon at gmail.com
Thu Jun 16 04:47:21 EDT 2016


how can list be synchronized when multiprocessor working in it?

will one thread updating non-updated version, but another processor updating the version?

On Thursday, June 16, 2016 at 4:30:33 PM UTC+8, Steven D'Aprano wrote:
> On Thursday 16 June 2016 17:28, meInvent bbird wrote:
> 
> > is there like c# have concurrent list ?
> 
> What is a concurrent list?
> 
> Can you link to the C# documentation for this?
> 
> To me, "concurrent" describes a style of execution flow, and "list" describes a 
> data structure. I am struggling to understand what "concurrent list" means.
> 
> > i find something these, but how can it pass an initlist list variable
> 
> initlist = ['a', 'b', 'c']
> result = comb(n, initlist)  # pass initlist
> 
> 
> > is it doing the same function as itertools.combinations ?
> 
> It is calling itertools.combinations. So, yes, it is doing the same function as 
> itertools.combinations.
> 
> 
> > def comb(n, initlist): # the argument n is the number of items to select
> >     res = list(itertools.combinations(initlist, n)) # create a list from the
> >                                                     # iterator 
> >     return res
> 
> This does not generate the combinations in parallel. It generates them one at a 
> time, and then creates a list of them.
> 
> This is an interesting question. Somebody could probably write a parallel 
> version of combinations. But I don't know that it would be very useful -- the 
> limiting factor on combinations is more likely to be memory, not time.
> 
> Suppose you generate combinations of 100 items, taken 10 at a time. If I 
> remember the formula for combinations correctly, the total number of 
> combinations is:
> 
> 100!/(10! * 90!) = 17310309456440
> 
> combinations in total. If each generated combination took just *one* byte of 
> memory, that would require over 17 TB of RAM.
> 
> 
> 
> -- 
> Steve




More information about the Python-list mailing list