[Python-Dev] Possible patch for functools partial - Interested?

Daniel Urban urban.dani+py at gmail.com
Fri May 14 06:39:12 CEST 2010


I wrote an e-mail yesterday, but it seems, it didn't reach python-dev.
Here it is again:

On Thu, May 13, 2010 at 13:30, Steven D'Aprano <steve at pearwood.info> wrote:
> I'd support an immutable dict. partial objects already impose a
> significant (~ 30%) performance penalty:
>
>>>> from timeit import Timer
>>>> min(Timer('f(5)', 'f = lambda x: x').repeat())
> 0.93580079078674316
>>>> min(Timer('p(5)', 'from functools import partial; p = partial(lambda
> x: x)').repeat())
> 1.2715129852294922
>
> No need to make that worse if that can be avoided.

I've made a new patch, in which the keywords attribute is a read-only
proxy of the dictionary. I've used your benchmark, and I haven't found
any significant difference in execution times.
The patch is in the tracker (http://bugs.python.org/issue8699) and
Rietveld (http://codereview.appspot.com/1179044).


Daniel Urban


More information about the Python-Dev mailing list