[Python-Dev] Partial function application 'from the right'

Nick Coghlan ncoghlan at gmail.com
Thu Jan 29 23:19:08 CET 2009

Leif Walsh wrote:
> That said, it seems to me that if we're going to add to
> functools.partial, we should go all the way and allow keyword
> arguments (or a dict of them, if it's otherwise too hard to
> implement).  Otherwise, in another few {days, weeks, months} we'll see
> another thread like this clamoring for a keyword-sensitive
> functools.partial.

functools.partial *does* support keyword arguments - it's just that some
functions and methods written in C (such as string methods) *don't*, so
partial's keyword support doesn't help.

A functools.rpartial would go some way towards addressing that.

Using the standalone Ellipsis to denote missing arguments would probably
start to miss the whole point of functools.partial: the only reason for
its existence is that it is *faster than the equivalent Python function*.

If partial starts messing about looking for missing arguments and then
slotting them in, then it is likely to slow down to the point where you
would be better off skipping it and writing a dedicated function that
adds the extra arguments.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list