future multi-threading for-loops
castironpi at gmail.com
castironpi at gmail.com
Tue Feb 5 00:46:04 EST 2008
On Feb 4, 9:22 pm, 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 )
>
> 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.
Some timing stats: On Windows XP, Python 3.0a2.
[timing code, 10,000 calls]
[ f( X ) ]: 0.0210021106034
[ start_new_thread( f, X ) ]: 1.15759908033
[ Thread( f, X ).start() ]: 1.85400099733
[ Thread( f, X ).start and .join() ]: 1.93716743329
Are threads an OS bottleneck?
More information about the Python-list
mailing list