2009-06-02

The curry diet

This might just work. That's really the best I can come up with to describe an odd little library that I've secretly been working on. It's called curry, because it's both cooking and currying.

Also referred to as partial application, currying is the transformation of a function of n variables into a chain of n functions of a single variable. That seemed a bit too mathematical for me to be of any practical use in Python, so my starting point is a bound method. The idea then is to apply partial application to this method to shift off the class instance pointer, partially evaluating the function body (recursively). This is actually a means of optimization and the motivation is to try and use it instead of code generation in libraries like chameleon. Rather than generating code, the idea is to reduce existing, working, tested code to obtain the exact same result.

There are more technical details available on the project page, while examples are included in the test suite.

0 comments: