➜

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.

classification
标题: Review performance of inspect.getfullargspec
类型: performance Stage: needs patch
Components: Versions:
process
状态: open Resolution:
Dependencies: 后续:
分配给: 抄送列表: hroncok, ncoghlan, pablogsal, yselivanov, zzzeek
优先级: normal 关键字:

ncoghlan 于 2019-05-22 12:19 创建。最近一次由 admin 于 2022-04-11 14:59 修改。

Messages (2)
msg343186 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) 日期: 2019-05-22 12:19
(Splitting out a separate performance issue from https://bugs.python.org/issue36751#msg342683)

There can be two quite different reasons for inspecting a function signature:

* inspecting arbitrary functions to learn as much about them as possible in order to present good coding hints and other guidance to a developer
* inspecting function and method implementations passed to a runtime API in order to call them correctly

inspect.signature focuses on the former use case, and as a result ended up being markedly slower than the simpler inspect.getfullargspec implementation that it replaced.

At the moment, inspect.getfullargspec is being kept around solely as a backwards compatibility API - it calls inspect.signature internally, but then throws away the rich objects that function creates, replacing them with simple Python builtins.

It seems plausible that we could reverse that relationship, and instead have inspect.signature use inspect.getfullargspec as a lower level API that produces less self-descriptive output, but also avoids creating a lot of instances of custom Python objects.

(Sample performance data can be seen in https://gist.github.com/zzzeek/0eb0636fa3917f36ffd887d9f765c208)
msg343202 - (view) Author: mike bayer (zzzeek) * 日期: 2019-05-22 15:39
thanks for creating this issue Nick!
历史
日期 用户 动作 参数
2022-04-11 14:59:15admin修改github: 81191
2019-05-22 16:13:47pablogsal修改抄送: + yselivanov, pablogsal
2019-05-22 15:39:07zzzeek修改抄送: + zzzeek
消息: + msg343202
2019-05-22 12:25:27hroncok修改抄送: + hroncok
2019-05-22 12:19:41ncoghlan创建