Title: Avoid allocating a result vector for a single ctypes output by youknowdot · Pull Request #9749 · RustPython/RustPython · GitHub
Open Graph Title: Avoid allocating a result vector for a single ctypes output by youknowdot · Pull Request #9749 · RustPython/RustPython
X Title: Avoid allocating a result vector for a single ctypes output by youknowdot · Pull Request #9749 · RustPython/RustPython
Description: Summary Follow up on #9618 without changing its OutValue representation or object ownership. For one OUT/INOUT result, convert/clone the borrowed value directly instead of collecting it into a temporary Vec and immediately extracting it. Multiple outputs still collect into a tuple. Raw-result disposal, errcheck short-circuiting, callback order, exception propagation, and the lifetime of all output owners are unchanged. This follows the singleton-result shape of CPython 3.15 _build_result. It is not a bitmask redesign or a claim of complete ctypes compatibility. Real native-call regression test The existing ordinary DLL constructor discards paramflags, so using that constructor would not exercise this path. The test fixture sets only the internal parameter metadata (as the COM constructor does), then executes Python calls through the actual VM and libffi to small native C-ABI functions. It checks single custom OUT conversion, original INOUT identity, multiple outputs, raw-result disposal order, errcheck replacement/identity, and conversion exceptions. It does not assert source tokens or macro expansion. The separate DLL-constructor/resolved-callargs/errcheck-argument behavior is deliberately not enabled or changed here. Original validation (before the November 11 rebase) Passed on Linux: cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi C-API cargo test Workspace and C-API Clippy with --all-targets -- -D warnings Native-call regression in both debug/workspace and release configurations Release -m test test_ctypes: SUCCESS (run=323, skipped=56) Existing extra_tests/snippets/stdlib_ctypes.py in debug and release Normal pre-commit hooks No throughput speedup percentage is claimed; this removes the singleton result-vector construction, not all allocations in a ctypes call. Windows/macOS CI remains to be checked. November 11 rebase Rebased independently onto dd8c34399621e60e703caeff89b2d5ae5c2f64f6 without changing the patch (git range-diff reports equality). Changed-file pre-commit hooks passed. Fresh CI for this head and local full validation are pending. The previous failed jobs stopped during external tool setup: HTTP 504 downloading Python, prek/reviewdog, and CodSpeed, and a missing Wasmer executable. None reported a failure in the changed ctypes code. AI assistance: OpenAI Codex assisted with implementation, testing, review, and the rebase.
Open Graph Description: Summary Follow up on #9618 without changing its OutValue representation or object ownership. For one OUT/INOUT result, convert/clone the borrowed value directly instead of collecting it into a temp...
X Description: Summary Follow up on #9618 without changing its OutValue representation or object ownership. For one OUT/INOUT result, convert/clone the borrowed value directly instead of collecting it into a temp...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9749
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:a0e3d0ea-ce0f-c653-4ffe-3996312a1503 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BC58:361639:2F9E86A:3F928B4:6B01E695 |
| html-safe-nonce | be5498a9608bfc29d4978b00e1d36dc1fe1e8ccacd4de6e7158d572b6f73f80c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzU4OjM2MTYzOToyRjlFODZBOjNGOTI4QjQ6NkIwMUU2OTUiLCJ2aXNpdG9yX2lkIjoiNjE2NjI0MzMwODM4NjUxMDQ4NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ccf0502649f3a39287c6713acdf108a53e89e4d941a443e74bf96028b0ed22eb |
| hovercard-subject-tag | pull_request:5210068452 |
| 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/9749/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 Follow up on #9618 without changing its OutValue representation or object ownership. For one OUT/INOUT result, convert/clone the borrowed value directly instead of collecting it into a temp... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width