New submission from STINNER Victor:
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?
----------
files: partial_call_kwargs.patch
keywords: patch
messages: 273456
nosy: haypo, rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: functools.partial: don't copy keywoard arguments in partial_call()?
type: performance
versions: Python 3.6
Added file: http://bugs.python.org/file44199/partial_call_kwargs.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27840>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com