Skip to content

mattharrison/coreit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

coreit
-------

Helper function to throw code on cores that can be run in parallel.

If you have code like

>>> for i in xrange(start, stop):
...     slow_function(i)

You can speed it up on a 4-core machine by running it like so:

>>> functions = [slow_function for i in xrange(start, stop)]
>>> args = [(i,) for i in xrange(start, stop)]
>>> coreit(functions, args, 4)

Note that 

>>> p = multiprocessing.Pool(4)
>>> p.map(slow_function, xrange(start, stop))

is built in and does the equivalent. 

As such, this code is somewhat obsolete, but has a distinction: if you
have *different* functions that you want to run concurrently, coreit
will do it.  Pool.map won't.

Requirements
-------------

* multiprocessing  (python 2.6 or http://code.google.com/p/python-multiprocessing/)

Todo
----

* ?

Licensed under PSF license
Copyright (c) 2010 Matt Harrison (matthewharrison@gmail.com)

About

Python helper to throw code on cores that can run in parallel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages