Skip to content

gh-87613: Pass borrowed *args and **kwargs through without Py_INCREF - #162781

Merged
kumaraditya303 merged 1 commit into
python:mainfrom
cmaloney:landable/clinic-borrow-varargs
Nov 30, 2026
Merged

kumaraditya303 merged 1 commit into
python:mainfrom
cmaloney:landable/clinic-borrow-varargs

Conversation

@cmaloney

@cmaloney cmaloney commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

When the generated argument parser recieves a tuple and a dict borrow them instead of taking a new reference. The caller holds both for the duration of the call.

Functions with a generated vectorcall keep the new reference: the vectorcall builds its own tuple and dict and shares the cleanup.

Found while investigating slowdowns trying to move Exception hierarchy which often uses *args to AC VC for gh-161242

…NCREF

When the generated argument parser recieves a tuple and a dict borrow
them instead of taking a new reference. The caller holds both for the
duration of the call.

Functions with a generated vectorcall keep the new reference: the
vectorcall builds its own tuple and dict and shares the cleanup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kumaraditya303
kumaraditya303 merged commit f77c71e into python:main Nov 30, 2026
77 checks passed
@cmaloney
cmaloney deleted the landable/clinic-borrow-varargs branch November 30, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants