Title: Argument Clinic: inline parsing code for 1-argument functions
Type: enhancement Stage: patch review
Components: Argument Clinic Versions: Python 3.8
Status: open Resolution:
Dependencies: 26305 26902 Superseder:
Assigned To: serhiy.storchaka Nosy List: ammar2, larry, serhiy.storchaka, vstinner, xtreak
Priority: normal Keywords: patch

Created on 2015-04-04 14:24 by serhiy.storchaka, last changed 2018-10-16 12:46 by ammar2.

File name Uploaded Description Edit
clinic_meth_o_inline.patch serhiy.storchaka, 2015-04-04 14:24 review
clinic_meth_o_inline.patch serhiy.storchaka, 2016-05-01 13:53 review
Pull Requests
URL Status Linked Edit
PR 9689 open serhiy.storchaka, 2018-10-03 14:48
Messages (7)
msg240074 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-04-04 14:24
Proposed patch makes Argument Clinic to inline parsing code for most popular formats in functions with single positional argument. This makes parsing faster.
msg264596 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-01 13:53
Synchronized with tip.
msg264629 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2016-05-02 06:51
Why is this dependent on #26305?
msg264631 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-02 09:04
Because new generated code contains "if" statements and braces (and PEP 7 requires even more braces than current patch adds). The patch for issue26305 allows to repeat braces only twice instead of 4 times.
msg286788 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-02-02 13:50
I like the idea since I just proposed something similar in the issue #29419, but it seems like your change removes the function name from error messages which can become much more obscure.

Maybe we should wrap all exceptions into a new TypeError which contains at least the function name, or even the parameter name/position. I mean chained exception to keep the original exception which contains more information.

The best would be to have all information in a single error message, but it is likely to be much more complex to implement, especially if you want to support arbitrary converter function, not only simple formats like  i". So I think that two chained exceptions is a reasonable compromise. What do you think?

If we succeed to get the function name and the parameter name or position, the error messages will be MUCH MORE better than currently! And Argument Clinic allows us to implement this feature.
msg326979 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-03 14:54
Thank you all for your comments. Addressed all comments, fixed few other bugs, added support for more convertors. I think this patch is completed.

This is just a first step. Next steps are adding support of multiple positional-only parameters, optional groups, and finally keyword parameters.
msg327493 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-10-10 21:22
I'm a little bit sad that the PR doesn't add new tests :-(
Date User Action Args
2018-10-16 12:46:44ammar2setnosy: + ammar2
2018-10-10 21:22:23vstinnersetmessages: + msg327493
2018-10-09 12:36:56xtreaksetnosy: + xtreak
2018-10-09 09:36:51serhiy.storchakasetassignee: serhiy.storchaka
2018-10-03 14:54:13serhiy.storchakasetmessages: + msg326979
versions: + Python 3.8, - Python 3.6
2018-10-03 14:48:53serhiy.storchakasetstage: needs patch -> patch review
pull_requests: + pull_request9076
2017-02-02 13:50:39vstinnersetnosy: + vstinner
messages: + msg286788
2016-06-09 12:23:06serhiy.storchakasetstage: patch review -> needs patch
2016-05-02 09:04:09serhiy.storchakasetmessages: + msg264631
2016-05-02 06:51:20larrysetmessages: + msg264629
2016-05-01 18:49:00serhiy.storchakasetdependencies: + Make Argument Clinic to generate PEP 7 conforming code, Argument Clinic incorrectly works with custom converter and renamed parameter
2016-05-01 13:53:50serhiy.storchakasetfiles: + clinic_meth_o_inline.patch

messages: + msg264596
versions: + Python 3.6, - Python 3.5
2015-04-04 14:24:36serhiy.storchakacreate