René's URL Explorer Experiment


Title: Make vectorcall and the native call ABI borrow their arguments · Issue #9850 · RustPython/RustPython · GitHub

Open Graph Title: Make vectorcall and the native call ABI borrow their arguments · Issue #9850 · RustPython/RustPython

X Title: Make vectorcall and the native call ABI borrow their arguments · Issue #9850 · RustPython/RustPython

Description: Summary RustPython's vectorcall copies the PEP 590 calling shape (nargs, kwnames) but not its main property: calling without copying the argument vector. Every generic call moves its arguments into an owned Vec, converts it into FuncArgs...

Open Graph Description: Summary RustPython's vectorcall copies the PEP 590 calling shape (nargs, kwnames) but not its main property: calling without copying the argument vector. Every generic call moves its arguments into...

X Description: Summary RustPython's vectorcall copies the PEP 590 calling shape (nargs, kwnames) but not its main property: calling without copying the argument vector. Every generic call moves its arguments ...

Opengraph URL: https://github.com/RustPython/RustPython/issues/9850

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Make vectorcall and the native call ABI borrow their arguments","articleBody":"## Summary\nRustPython's vectorcall copies the PEP 590 calling shape (`nargs`, `kwnames`) but not its main property: calling without copying the argument vector. Every generic call moves its arguments into an owned `Vec`, converts it into `FuncArgs` (copying keyword names into a map), and then binds positional arguments by popping the front of that `Vec`. CPython does none of this. This issue compares the two designs and proposes a plan to make the native call path borrow its arguments.\n\nFound while reviewing #9758, where the method descriptor now does `args.remove(0)` to take the receiver out of band (`crates/vm/src/builtins/descriptor.rs`, `vectorcall_method_descriptor`). That shift is not new: before #9758 the same `remove(0)` ran inside `FuncArgs::take_positional`. It is a symptom of the owned-`Vec` design, not of the receiver change.\n\n## Comparison\n\n| | CPython | RustPython today |\n|---|---|---|\n| Vectorcall arguments | `PyObject *const *args`, borrowed from the caller's stack (`vectorcallfunc`, `Include/object.h`) | `Vec\u003cPyObjectRef>`, owned (`VectorCallFunc`, `crates/vm/src/types/slot.rs`) |\n| Skip the first argument | `args+1, nargs-1`, pointer arithmetic (`method_vectorcall_*`, `Objects/descrobject.c`) | `args.remove(0)`, memmove (`vectorcall_method_descriptor`) |\n| Prepend `self` | Write into the reserved `args[-1]` slot when `PY_VECTORCALL_ARGUMENTS_OFFSET` (`Include/abstract.h`) is set (`method_vectorcall`, `Objects/classobject.c`) | `args.insert(0, self)`, memmove (`vectorcall_bound_method`, `crates/vm/src/builtins/function.rs`; `frame.rs` call-with-self paths) |\n| Native function ABI | `METH_FASTCALL\\|METH_KEYWORDS`: `meth(self, args, nargs, kwnames)`, all borrowed (`cfunction_vectorcall_FASTCALL_KEYWORDS`, `Objects/methodobject.c`) | `PyNativeFn(vm, receiver, FuncArgs, Callee)`, where `FuncArgs` owns a `Vec` and a keyword map |\n| Keyword arguments | `kwnames` tuple passed through unchanged | `FuncArgs::from_vectorcall_owned` builds a map and copies every keyword name (`as_wtf8().to_owned()`) |\n| Positional binding | Index into `args` (Argument Clinic generated code) | `FuncArgs::take_positional` = `args.remove(0)` per argument, so O(n²) memmove over n arguments |\n\n## What already avoids the cost\n- The `frame.rs` specializations (`CallMethodDescriptor{Noargs,O,Fast,FastWithKeywords}`, builtin call specializations) take arguments directly from the value stack, and the receiver without shifting (`execute_call_method_descriptor`, `take_native_method_args`).\n- `#[from_args(borrowed)]` / `BorrowedArgs` binds against the caller's storage without per-argument ownership transfer.\n\nSo the hot specialized paths are mostly fine. The remaining cost is on every generic call: unspecialized sites, calls through `map`/`sorted(key=)`/`functools`, `PyObject_Vectorcall` from native code, bound Python methods, and C-API calls.\n\n## Plan\nEach step should land separately, keep every error message unchanged, and come with before/after benchmarks.\n\n1. **Borrowed vectorcall arguments.** Change `VectorCallFunc` to take a borrowed argument slice (`&[PyObjectRef]` or an equivalent borrowed view), `nargsf` with an `ARGUMENTS_OFFSET` bit, and `kwnames`. Callers that build arguments on the value stack pass a stack slice with no `Vec` allocation. Callers that want to prepend `self` reserve slot `-1` and set the offset bit, which removes the `insert(0, ...)` in `vectorcall_bound_method` and the call-with-self paths in `frame.rs`. Callees that need ownership (for example a Python frame's `localsplus`) clone from the slice, which costs the same refcount increments as today's move plus no allocation.\n2. **Native ABI without `FuncArgs` ownership.** Give native functions a borrowed argument view (`args`, `nargs`, `kwnames`), as `METH_FASTCALL|METH_KEYWORDS` does. `FuncArgs` stays as the owned form for `tp_call`-style and `*args/**kwargs` paths. The method descriptor then passes `&args[1..]` and the receiver with no shift, and builtin functions pass the slice unchanged.\n3. **Index-based binding.** Make `FromArgs` binders consume positionals by index (a cursor over the borrowed view) instead of `take_positional`'s `remove(0)`, and look keywords up in `kwnames` instead of a prebuilt map. This removes both the per-argument memmove and the keyword-name copies. Generated binders should match Clinic's parsing order and messages.\n4. **C-API.** Pass the borrowed view straight to `METH_FASTCALL` C functions instead of materializing a temporary array.\n\n## Validation\n- Workspace tests, C-API tests, Clippy, `-m test test_descr test_inspect test_builtin test_call test_capi test_functools`.\n- Micro-benchmarks before and after each step (release build, several interleaved samples, medians):\n  - unspecialized builtin call with keywords (e.g. `sorted(l, key=f)` setup, `int(x, base=10)` through `map`)\n  - unbound descriptor call through a generic path (`map(list.append, ...)`-style)\n  - bound Python method call (`obj.method(x)` via a stored bound method)\n  - `PyObject_Vectorcall` from a C extension\n\n— *commented by Claude*\n","author":{"url":"https://github.com/youknowone","@type":"Person","name":"youknowone"},"datePublished":"2026-11-15T07:49:47Z","url":"https://github.com/RustPython/RustPython/issues/9850"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:13506b93-2086-0f80-51e6-65dc3d5f46b1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEAB6:4279A:2A06D42:38914BD:6B01D40D
html-safe-noncee5a587fb400c4a59d48ee3830c2e61bc4524db3d91d7b0a3461adf6281224450
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQUI2OjQyNzlBOjJBMDZENDI6Mzg5MTRCRDo2QjAxRDQwRCIsInZpc2l0b3JfaWQiOiI3NTgyODcyMTQ5OTUwNTgzODIxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac1531b67fc1d70447e12656b3a26cc21c7788616d7381317bec9f8bc9eab5a61c
hovercard-subject-tagissue:6401503709
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/RustPython/RustPython/9850/issue_layout
twitter:imagehttps://opengraph.githubassets.com/65e95153414104e35a80caa158400841249a5ad7c56bdf0e8fc396e158910f70/RustPython/RustPython/issues/9850
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/65e95153414104e35a80caa158400841249a5ad7c56bdf0e8fc396e158910f70/RustPython/RustPython/issues/9850
og:image:altSummary RustPython's vectorcall copies the PEP 590 calling shape (nargs, kwnames) but not its main property: calling without copying the argument vector. Every generic call moves its arguments into...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameyouknowone
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git
octolytics-dimension-user_id39710557
octolytics-dimension-user_loginRustPython
octolytics-dimension-repository_id135201145
octolytics-dimension-repository_nwoRustPython/RustPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id135201145
octolytics-dimension-repository_network_root_nwoRustPython/RustPython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/RustPython/RustPython/issues/9850#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fissues%2F9850
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fissues%2F9850
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/issues/9850
Reloadhttps://github.com/RustPython/RustPython/issues/9850
Reloadhttps://github.com/RustPython/RustPython/issues/9850
RustPythonhttps://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Codehttps://github.com/RustPython/RustPython
Issues195 (195)https://github.com/RustPython/RustPython/issues
Pull requests132 (132)https://github.com/RustPython/RustPython/pulls
Discussionshttps://github.com/RustPython/RustPython/discussions
Actionshttps://github.com/RustPython/RustPython/actions
Projectshttps://github.com/RustPython/RustPython/projects
Wikihttps://github.com/RustPython/RustPython/wiki
Security and qualityhttps://github.com/RustPython/RustPython/security
Insightshttps://github.com/RustPython/RustPython/insights
https://github.com/RustPython/RustPython
New issuehttps://github.com/login?return_to=https://github.com/RustPython/RustPython/issues/9850
New issuehttps://github.com/login?return_to=https://github.com/RustPython/RustPython/issues/9850
Make vectorcall and the native call ABI borrow their argumentshttps://github.com/RustPython/RustPython/issues/9850#top
https://github.com/youknowone
youknowonehttps://github.com/youknowone
on Nov 15, 2026https://github.com/RustPython/RustPython/issues/9850#issue-6401503709
#9758https://github.com/RustPython/RustPython/pull/9758
#9758https://github.com/RustPython/RustPython/pull/9758
https://github.com/youknowdot
youknowdothttps://github.com/youknowdot
on Nov 15, 2026https://github.com/RustPython/RustPython/issues/9850#issuecomment-6892740501
RustPython stackref ownership conversionhttps://github.com/RustPython/RustPython/blob/9d209ae699f340338455fec9d1523535079ed9cb/crates/vm/src/object/core.rs#L2611-L2630
RustPython exact Python-function vectorcallhttps://github.com/RustPython/RustPython/blob/9d209ae699f340338455fec9d1523535079ed9cb/crates/vm/src/builtins/function.rs#L1859-L1949
RustPython C-API FASTCALL bridgehttps://github.com/RustPython/RustPython/blob/9d209ae699f340338455fec9d1523535079ed9cb/crates/capi/src/methodobject.rs#L194-L239
CPython 3.15.2 _DO_CALLhttps://github.com/python/cpython/blob/v3.15.2/Python/bytecodes.c#L4385-L4434
CPython 3.15.2 frame initialization ownership contracthttps://github.com/python/cpython/blob/v3.15.2/Python/ceval.c#L2032-L2065
Sign up for freehttps://github.com/signup?return_to=https://github.com/RustPython/RustPython/issues/9850
Sign in to commenthttps://github.com/login?return_to=https://github.com/RustPython/RustPython/issues/9850
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.