[issue24190] BoundArguments facility to inject defaults

2015-05-16 Thread Roundup Robot
Roundup Robot added the comment: New changeset ea61d8eb8a28 by Yury Selivanov in branch 'default': Issue 24190: Add inspect.BoundArguments.apply_defaults() method. https://hg.python.org/cpython/rev/ea61d8eb8a28 -- nosy: +python-dev ___ Python tracker

[issue24190] BoundArguments facility to inject defaults

2015-05-16 Thread Yury Selivanov
Yury Selivanov added the comment: Thanks for the suggestion, Antoine! -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24190

[issue24190] BoundArguments facility to inject defaults

2015-05-14 Thread Yury Selivanov
Yury Selivanov added the comment: Well, the docs example only binds explicit defaults in function signature. Implicit defaults for *args and **kwargs (`()` and `{}`) aren't usually useful (in my opinion). Do you guys have any good use case for such method? I use the Signature API

[issue24190] BoundArguments facility to inject defaults

2015-05-14 Thread Yury Selivanov
Yury Selivanov added the comment: FWIW it wasn't as easy as I thought it would be :) You were right, docs example is very basic. Please take a look at the attached patch. -- assignee: - yselivanov keywords: +patch stage: - patch review Added file:

[issue24190] BoundArguments facility to inject defaults

2015-05-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: Le 14/05/2015 17:45, Yury Selivanov a écrit : Well, the docs example only binds explicit defaults in function signature. Implicit defaults for *args and **kwargs (`()` and `{}`) aren't usually useful (in my opinion). When the defaults are filled I expect

[issue24190] BoundArguments facility to inject defaults

2015-05-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: That sounds good to me, thank you! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24190 ___ ___

[issue24190] BoundArguments facility to inject defaults

2015-05-14 Thread Yury Selivanov
Yury Selivanov added the comment: Do you guys have any good use case for such method? A use case was given in issue22998. My use case is JIT-compiling functions and function calls in Numba. We reimplement the function calls ourselves, so need a complete mapping of arguments to values.

[issue24190] BoundArguments facility to inject defaults

2015-05-14 Thread R. David Murray
R. David Murray added the comment: See issue 22998. The more complete and thus more complex example in the last message makes it look like including this in the library might be a good idea. -- nosy: +r.david.murray ___ Python tracker

[issue24190] BoundArguments facility to inject defaults

2015-05-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: My example forgets the function declaration, which is: def f(a, b=5, *c, d=5): pass ... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24190 ___

[issue24190] BoundArguments facility to inject defaults

2015-05-14 Thread Antoine Pitrou
New submission from Antoine Pitrou: The recipe to inject default values in a BoundArguments instance is given in the doc, but it's not trivial. Furthermore, it's actually incomplete: it doesn't handle any star-arguments, e.g.: sig = inspect.signature(f) ba = sig.bind(2, d=4) for param in