Title: Bind interpreter arguments with borrowed Clinic structs by youknowdot · Pull Request #9763 · RustPython/RustPython · GitHub
Open Graph Title: Bind interpreter arguments with borrowed Clinic structs by youknowdot · Pull Request #9763 · RustPython/RustPython
X Title: Bind interpreter arguments with borrowed Clinic structs by youknowdot · Pull Request #9763 · RustPython/RustPython
Description: Summary Replace the display-only signature_args wrappers and _interpreters' duplicated ArgSpec parsers with borrowed Clinic argument structs. Extend #[derive(FromArgs)] with #[from_args(borrowed)]. The native wrapper owns the original FuncArgs through argument conversion, the implementation, and return conversion. Generated fields borrow that storage. Bind and validate each slot once before any converter runs, using the existing Clinic shape/count rules and #9790's matched-keyword approach. Positional calls without keywords skip keyword lookup. Generate binding and signature metadata from the same fields. _interpreters no longer opts out of Clinic validation to expose signatures. Convert borrowed objects, typed payload references, and flags in Clinic declaration order. Preserve payload-specific validation such as PyUtf8Str's surrogate error. Release borrowed native arguments in reverse evaluation-stack order. Retain original expanded-call containers through native, bound-method, callable-object, and instrumented calls, and release tuple members in reverse order. Keep the existing owned and explicit legacy paths. Borrowing currently supports finite structs with one lifetime, passed as the sole arguments struct plus the VM. Unsupported layouts and display defaults without omission handling are rejected at compile time. This builds on #9563 and #9729 and is based on main dd8c34399. Validation Reference: CPython 3.15.1 Clinic wrappers. 273 binding/error cases match CPython exactly, including call(-1, None, args=None, unexpected=1) reporting the unexpected keyword first. 15 inspected and whitespace-normalized raw signatures match. call's raw line wrapping still differs; no exact raw-match claim is made for that string. 585 lifetime/error comparisons across 15 Clinic functions and nine call forms match CPython 3.15.1, including reordered keywords, positional/keyword mixtures, unpacking, binding errors, typed conversion errors, and boolean conversion exceptions. New regressions cover direct/expanded native cleanup, exact Python functions versus bound methods and callable objects, tuple-subclass iteration, nested/subclass tuple destruction, raising bodies, and monitoring transitions. Existing owned native converters and Python-function binding-failure cleanup are not migrated here. This is not a universal call-lifetime parity claim. Derive tests check for one binding invocation and no owning copies, allocation containers, or second binding pass. VM tests check reference identity/counts and Clinic error precedence. A local two-field borrowed-object counting-allocator probe over 100,000 positional and 100,000 keyword bindings measured zero allocations and unchanged input reference counts. Generated and equivalent handwritten extraction perform the same successful-path work in optimized x86-64 assembly; cold panic locations and function addresses differ. This is scoped evidence for the abstraction, not a claim that conversions or diagnostics can never allocate. Local validation: cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi: passed, including the borrowed derive/payload regressions and doctests. C-API tests from crates/capi on the final head: 149 passed, 2 ignored. Workspace and separate C-API Clippy runs with --all-targets -- -D warnings: passed. The full extra_tests run with the final release binary and CPython 3.15.1 had 491 passed, 20 failed, 15 subtests passed. All 20 failure IDs reproduce with the previous head binary: restricted multiprocessing/NETLINK operations, filesystem EINVAL, unavailable _sqlite3/CPython test modules, and existing CPython snippet incompatibilities. The three changed snippets pass on both interpreters. These failures are not counted as passes. test_call, test_extcall, test_tuple, test_monitoring, test_funcattrs, and test_generators: passed (426 tests reported, 193 skipped). test_interpreters.test_api remains skipped because this build has the GIL disabled, so it is not claimed as coverage. Repository pre-commit hooks: passed on every commit. Common borrowed binding still adds zero allocations or reference-count clones. Non-tuple *iterable calls to non-Python callables now retain a normalized argument snapshot, which requires one additional Vec and one clone/drop pair per positional value. Exact-tuple calls retain their existing owner without this snapshot allocation. Final Linux x86-64 alternating-process microbenchmarks put native *tuple calls about 3–4% slower and native *list calls 8–9% slower than 635291497. Ordinary Python expansion paths were approximately baseline; native **kwargs improved about 3%. Direct borrowed-call measurements varied by about +1–6% across focused/broad samples, so no universal zero-runtime-overhead claim is made. Expanded-call collection now keeps owner state local, preallocates keyword space, and specializes instrumentation at compile time; borrowed cleanup is inlined, confirmed in assembly. CI for head 5157ca191102b4985c23144dd37af5fdc52b4e71 is tracked in this run. This PR remains a draft. AI-assisted implementation, tests, and review using OpenAI Codex.
Open Graph Description: Summary Replace the display-only signature_args wrappers and _interpreters' duplicated ArgSpec parsers with borrowed Clinic argument structs. Extend #[derive(FromArgs)] with #[from_args(borrow...
X Description: Summary Replace the display-only signature_args wrappers and _interpreters' duplicated ArgSpec parsers with borrowed Clinic argument structs. Extend #[derive(FromArgs)] with #[from_args(bo...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9763
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:e87c77d3-70bf-1e24-e0bd-a6552155530a |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D3B8:2AF0D8:25B0E:2F1E7:6B01E961 |
| html-safe-nonce | 85253fae28131d79d5851d8265d0ff3ce685b2ccdf9964ac39a4efc91f20d752 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0I4OjJBRjBEODoyNUIwRToyRjFFNzo2QjAxRTk2MSIsInZpc2l0b3JfaWQiOiI3MDUwMTY4MzY1NTQ1MDIzODQxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c1665dfe3801efa2b9bfdde819f44675196e44e4a451e760b95aa5095fbd53a6 |
| hovercard-subject-tag | pull_request:5224526854 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/9763/files |
| twitter:image | https://avatars.githubusercontent.com/u/336763669?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/336763669?s=400&v=4 |
| og:image:alt | Summary Replace the display-only signature_args wrappers and _interpreters' duplicated ArgSpec parsers with borrowed Clinic argument structs. Extend #[derive(FromArgs)] with #[from_args(borrow... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width