future multi-threading for-loops
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Tue Feb 5 02:21:25 EST 2008
On Mon, 04 Feb 2008 19:22:29 -0800, castironpi wrote:
> Some iterables and control loops can be multithreaded. Worries that
> it takes a syntax change.
>
> for X in A:
> def f( x ):
> normal suite( x )
> start_new_thread( target= f, args= ( X, ) )
>
> Perhaps a control-flow wrapper, or method on iterable.
>
> @parallel
> for X in A:
> normal suite( X )
>
> for X in parallel( A ):
> normal suite( X )
>
> Discussion presued about multi-core systems. Allow user certain
> control over what runs on multi-core. Clearly, not generally
> applicable. -- But, from __future__ import does change syntax.
Why not simply writing a function?
def execute_parallel(f, A):
for args in A:
start_new_thread(target=f, args=args)
def f(x):
normal_suit(x)
parallel(f, A)
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list