future multi-threading for-loops

dmitrey dmitrey.kroshko at scipy.org
Tue Feb 5 18:42:13 CET 2008


On Feb 5, 5:22 am, castiro... at gmail.com 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 )
>
I would propose "for X IN A" for parallel and remain "for X in A" for
sequential.
BTW for fortress lang I had proposed "for X <- A" and "for X <= A" for
sequential/parallel instead of current "for X <- seq(A)", "for X <-
A", mb they will implement my way instead.



More information about the Python-list mailing list