This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2018年09月28日 21:15 by rhettinger, last changed 2022年04月11日 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 9659 | merged | ammar2, 2018年10月01日 18:26 | |
| Messages (8) | |||
|---|---|---|---|
| msg326659 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2018年09月28日 21:15 | |
An arg clinic specification such as p: object(subclass_of='&PyTuple_Type') generates slow code using _PyArg_ParseStack() that has to parse a format string like "O!" to decide to make a type check. Instead, it should directly generate a branch-predictable test for the type check and then call the much quicker function _PyArg_UnpackStack(). See https://github.com/python/cpython/pull/9628 for an example of this change giving a 30% speedup. |
|||
| msg326819 - (view) | Author: Ammar Askar (ammar2) * (Python committer) | Date: 2018年10月01日 18:26 | |
I've attached a PR that implements this. From the looks of it, there aren't a lot of uses of subclass_of within argument clinic converted functions at the moment. Additionally, most of the places it is used tend to have some non object arguments so a call to _PyArg_ParseStack() gets placed anyway. Attached as part of separate commit in the PR is the conversion of some files over to use the new code. These are mostly just to serve as examples. While converting would still leave a call to ParseStack in most places, I'd like to do some benchmarking and figure out if there is still a benefit. Like you said, the fact that branch-prediction is easier might be useful given that these functions are usually called with the right types of arguments anyway. |
|||
| msg326980 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2018年10月03日 15:00 | |
Thank you for your PR Ammar. But I work on more general changes. The first step is issue23867. With implementing the second step this issue can be closed. |
|||
| msg327012 - (view) | Author: Ammar Askar (ammar2) * (Python committer) | Date: 2018年10月03日 20:12 | |
Aah, I didn't know that ticket existed. Thanks for the link Serhiy, I'll review your PR instead. Leaving it up to Raymond if he wants to close the issue and use the other one to track this. |
|||
| msg333471 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2019年01月11日 14:09 | |
PR 9659 is mostly superseded by issue35582. But it may contain other changes. Ammar, do you mind to create a new PR or merge the old PR with the current master? |
|||
| msg333494 - (view) | Author: Ammar Askar (ammar2) * (Python committer) | Date: 2019年01月11日 17:45 | |
Sounds good, I'll take a look at the changes and update the PR accordingly. |
|||
| msg333509 - (view) | Author: Ammar Askar (ammar2) * (Python committer) | Date: 2019年01月12日 03:18 | |
Great job Serhiy, your work on argument clinic has encompassed the previous PR very well. I've updated it for the changes. |
|||
| msg333512 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2019年01月12日 06:23 | |
New changeset cb08a71c5c534f33d9486677534dafb087c30e8c by Serhiy Storchaka (Ammar Askar) in branch 'master': bpo-34838: Use subclass_of for math.dist. (GH-9659) https://github.com/python/cpython/commit/cb08a71c5c534f33d9486677534dafb087c30e8c |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:59:06 | admin | set | github: 79019 |
| 2019年01月12日 06:31:09 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: resolved |
| 2019年01月12日 06:23:44 | serhiy.storchaka | set | messages: + msg333512 |
| 2019年01月12日 03:18:04 | ammar2 | set | messages: + msg333509 |
| 2019年01月11日 17:45:27 | ammar2 | set | messages: + msg333494 |
| 2019年01月11日 14:09:16 | serhiy.storchaka | set | messages: + msg333471 |
| 2019年01月05日 16:43:58 | serhiy.storchaka | set | dependencies: + Argument Clinic: inline parsing code for 1-argument functions, Argument Clinic: inline parsing code for functions with only positional parameters |
| 2018年10月03日 20:12:55 | ammar2 | set | messages: + msg327012 |
| 2018年10月03日 15:00:40 | serhiy.storchaka | set | messages: + msg326980 |
| 2018年10月01日 18:26:20 | ammar2 | set | nosy:
+ ammar2 messages: + msg326819 stage: patch review -> (no value) |
| 2018年10月01日 18:26:11 | ammar2 | set | keywords:
+ patch stage: patch review pull_requests: + pull_request9052 |
| 2018年09月28日 23:26:42 | eric.smith | set | nosy:
+ eric.smith |
| 2018年09月28日 21:46:15 | vstinner | set | nosy:
- vstinner |
| 2018年09月28日 21:20:13 | serhiy.storchaka | set | assignee: serhiy.storchaka |
| 2018年09月28日 21:15:58 | rhettinger | create | |