On Wed, 2006-09-06 at 22:49 -0700, Michael Spencer wrote: > If you're really hunting for speed, there is a significant boost available in > the common special case of a python function curried with one positional > argument. In this case, you can [ab]use the method binding machinery, e.g.: > > def curry3(_curried_fct, *args, **kwargs): > if len(args) == 1: > # Special case where we try to abuse the descriptor > try: > return _curried_fct.__get__(args[0]) > except AttributeError: > # built-ins fail - handle them in the normal way > pass > > def _curried(*moreargs, **morekwargs): > return _curried_fct (*(args+moreargs), **dict(kwargs, ** morekwargs)) > > return _curried > > > This is about twice as fast as curry2 for the case of a python function > curried > with one argument. It also offers better introspection than either curry1 or > curry2, since the original signature is preserved. It's a bigger change than > the curry2 though, since it changes the type of the curry from function to > bound > method. > I like this idea, but I'm curious about that last sentence. Is this necessarily a bad thing? Or maybe I should ask, why does it matter, function vs bound method. Aren't they both callable?
Or am I missing something? /Marc DM --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers -~----------~----~----~----~------~----~------~--~---
