Language Enhancement Idea to help with multi-processing (your opinions please)
Martin P. Hellwig
martin.hellwig at gmail.com
Thu Oct 13 16:20:13 EDT 2011
On 13/10/2011 15:13, Stefan Behnel wrote:
> Martin P. Hellwig, 13.10.2011 14:35:
>> I was wondering if there could be an advantage to add another control
>> flow
>> statement.
>
> Changes at that level must be very well justified, are often rejected
> for the reason of being not too complicated to write in some other form
> and are close to impossible to get accepted when requiring a new keyword.
>
> Also, the right place to discuss (and, more importantly, search for
> previous) ideas about language changes is the python-ideas mailing list.
>
>
>> For the purpose of this writing let's say "ooo" which stands for 'out of
>> order'.
>>
>> For example;
>>
>> def do_something():
>> a = 4
>> b = 2
>> c = 1
>> ooo:
>> a += 1
>> b += 2
>> c += 3
>> print(a, b, c)
>>
>> What I would expect to happen that all statements within the ooo block
>> may
>> be executed out
>> of order. The block itself waits till all statements are returned before
>> continuing.
>
> This looks like a rather special case. What if you need more than one
> statement to accomplish a single step?
Aah yes haven't thought about that, was more thinking like wrap multiple
steps in a function and put that as one line, but yeah that kind of
stuff gets very unpythonic very quickly.
> What if the number of parallel
> tasks is not fixed at coding time? I don't think there are many problems
> that you can solve with this feature.
>
> Also: the GIL will not allow you to take a major advantage from the
> parallel execution of a set of statements, as only one of the statements
> can use the interpreter at a time.
Well I was more or less thinking in the line that the interpreter when
parsing such a statement can, if there are multiple cpu's available,
fire the appropriate amount of other interpreters and do all the passing
and locking of data for you.
>
> And, on a related note: Cython has freshly gained support for parallel
> loops based on OpenMP, so you may be able to solve your problem with
> Cython instead of using plain Python.
>
Well funny enough I don't really have a problem with it, I am a happy
consumer of multiprocessing, but I was just wondering if there would be
a way to do it simpler and more pythonic.
> Stefan
>
Thanks for your feedback it was very enlightening although for what the
idea is concerned disappointing as it more or less makes it obvious that
such a thing is a no-go.
Cheers,
Martin
More information about the Python-list
mailing list