I justed optimized partial_call() for positional arguments in the change c1a698edfa1b to avoid the creation of a temporary tuple when possible.
I noticed that keyword parameters from partial() constructor are always copied. Is it mandatory? Can't we avoid copying them?
Example:
---
import functools
hello = functools.partial(print, "Hello World", end='!\n')
hello()
---
hello keyword arguments are {'end'; '!\n'}.
Attached patch avoids copying keyword arguments when the partial objects is not called with new keyword arguments.
Tests pass, but I don't know if there is a risk that some strange function modify keyword arguments in-place? |