Curry is a project mainly written in PYTHON and SHELL, it's free.
Pickle-able partial functions for Python
Description "The spice must flow!" In this case, we need functions to sate our addiction.
curry is a module that allows (almost) arbitrary python functions (with some caveats) to be pickled and remotely executed.
curry works with both pickle and cPickle python modules.
Caveats * Python versions Due to a dependence on the marshal* module, the version of python that unpickles and executes the curried function needs to be the same as the version that pickled the function. See the [[http://docs.python.org/library/marshal][marshal module]] for more details.
* Subclassing While curry.curry looks like function application, it is really a constructor for a class implementing the /call/ method. Due to the way objects are pickled, subclassing curry.curry* is prohibited.
* Recursive currying/partial application Do not try to curry an already curried object or a function obtained from applying functools.partial*.
** Function default parameters In order to avoid problems do not directly specify default keyword arguments.
def foo(x, y, z=1): pass
Instead pop the defaults out of the /**kwargs/ dictionary:
def foo(x, y, **kws): z = kws.pop('z', 1)
Installation
$ python setup.py install
Example
import curry import pickle
def foo(x, y, *kws) z = kws.pop('z', 1) return x y * z
fn = curry.curry(foo, 3, z=9)
with open('function.pkl', 'w') as fd: pickle.dump(fn, fd)
with open('function.pkl') as fd: h = pickle.load(fd)
print h(6)