Skip to content

Review performance of inspect.getfullargspec #81191

Open

Description

@ncoghlan
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 = []

Activity

  1. ncoghlan commented on May 22, 2019

    @ncoghlan
    ContributorAuthor

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

  2. zzzeek commented on May 22, 2019

    zzzeekmannequin
    Mannequin

    thanks for creating this issue Nick!

  3. transferred this issue fromon Apr 10, 2022
  4. added
    3.12only security fixes
    stdlibStandard Library Python modules in the Lib/ directory
    on Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesperformancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directory

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions