Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review performance of inspect.getfullargspec #81191

Open
ncoghlan opened this issue May 22, 2019 · 2 comments
Open

Review performance of inspect.getfullargspec #81191

ncoghlan opened this issue May 22, 2019 · 2 comments
Labels
3.12 bugs and security fixes performance Performance or resource usage stdlib Python modules in the Lib dir

Comments

@ncoghlan
Copy link
Contributor

BPO 37010
Nosy @ncoghlan, @1st1, @hroncok, @pablogsal

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2019-05-22.12:19:41.727>
labels = ['performance']
title = 'Review performance of inspect.getfullargspec'
updated_at = <Date 2019-05-22.16:13:47.599>
user = 'https://github.com/ncoghlan'

bugs.python.org fields:

activity = <Date 2019-05-22.16:13:47.599>
actor = 'pablogsal'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2019-05-22.12:19:41.727>
creator = 'ncoghlan'
dependencies = []
files = []
hgrepos = []
issue_num = 37010
keywords = []
message_count = 2.0
messages = ['343186', '343202']
nosy_count = 5.0
nosy_names = ['ncoghlan', 'zzzeek', 'yselivanov', 'hroncok', 'pablogsal']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'performance'
url = 'https://bugs.python.org/issue37010'
versions = []

@ncoghlan
Copy link
Contributor Author

(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)

@ncoghlan ncoghlan added the performance Performance or resource usage label May 22, 2019
@zzzeek
Copy link
Mannequin

zzzeek mannequin commented May 22, 2019

thanks for creating this issue Nick!

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@iritkatriel iritkatriel added 3.12 bugs and security fixes stdlib Python modules in the Lib dir labels Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes performance Performance or resource usage stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

2 participants