Title: Align bisect bounds and callback controls by youknowdot · Pull Request #9629 · RustPython/RustPython · GitHub
Open Graph Title: Align bisect bounds and callback controls by youknowdot · Pull Request #9629 · RustPython/RustPython
X Title: Align bisect bounds and callback controls by youknowdot · Pull Request #9629 · RustPython/RustPython
Description: Summary Consolidate the bisect bounds/callback work and #9630's insort result-disposal fix. Request sequence length only for an omitted, None, or -1 upper bound. Snapshot the sequence item slot even for an empty range. Bind the call before running __index__, finish lo conversion and nonnegative validation before converting hi, and preserve the original arguments through callbacks and insertion-result disposal. Restore CPython's native recursion guard around each search, including the cached same-type comparison path. Release the current item after leaving recursion on failure. Cache the original needle type's identity and comparison slot without retaining the type. Keep the shortcut across mixed-type probes and disable it after NotImplemented. Match the distinct lo and hi overflow/type diagnostics, including 200-byte type-name truncation. Discard custom insert() results and return None from both insort directions. Conversion and ownership The bound fields remain deferred objects because plain eager ArgIndex does not include native-size/negative validation and would convert hi too soon. Conversion still uses the shared ArgIndex, now through TryFromBorrowedObject; its existing owned interface is preserved by the blanket implementation. This removes an input incref/decref per supplied bound. The search stores a pointer-sized type identity rather than another type owner. Unkeyed insort borrows the existing input instead of cloning it. Error cleanup moves the existing midpoint owner, with no new allocation or incref/decref. The native recursion check runs once per search, matching CPython. Consolidation The branch includes current main at 1875dd8b207d and the latest #9630 head 28395170fc39 as merge ancestors. #9630's final redundant-clone lint expectations are superseded by borrowed arguments; its result-disposal and input-lifetime behavior is retained. No unrelated PR is included. Validation Independent source review against CPython 3.15.0 passed. Native release build passed. test_bisect: all 46 tests passed. Expanded extra_tests/snippets/stdlib_bisect.py passed on RustPython and CPython 3.15.0, including all-native recursion, conversion ordering/errors, type ownership, and insert-result disposal. The 56-line bounds/callback observable probe and eight additional ownership/error-cleanup cases matched CPython 3.15.0 exactly. Full-workspace all-targets Clippy and separate C-API all-targets Clippy passed with -D warnings. Full-workspace Rust tests passed (excluding wasm, venvlauncher, and C-API as prescribed). Separate C-API tests passed: 149 passed, 2 ignored. Normal commit hooks and formatting passed. The class-collection regression uses a separate assignment helper so it tests bisect's cached ownership independently of RustPython's existing rule retaining reassigned classes until the assigning frame exits. This PR does not change that VM-wide lifetime policy or add the existing missing exact-list insertion fast path. Cross-platform runtime validation has not been run. Summary by CodeRabbit Bug Fixes Improved bisect and insertion handling of search bounds, including negative or oversized values, invalid types, and omitted bounds. Corrected insertion behavior when using a key function; insertion methods return None. Improved error handling for recursive comparisons, indexing, and comparison callbacks. Added recursion-depth checks on WebAssembly builds. Tests Added coverage for argument validation, conversion errors, recursive comparisons, and insertion behavior.
Open Graph Description: Summary Consolidate the bisect bounds/callback work and #9630's insort result-disposal fix. Request sequence length only for an omitted, None, or -1 upper bound. Snapshot the sequence item slo...
X Description: Summary Consolidate the bisect bounds/callback work and #9630's insort result-disposal fix. Request sequence length only for an omitted, None, or -1 upper bound. Snapshot the sequence item...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9629
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:e4dc0e13-e635-08d1-d70d-b4666f23cc48 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A684:2A98A:FBD28:13D1FB:6B01FE37 |
| html-safe-nonce | 90af9ea05458b61f2a4735cb4ec4ffe64edba044cfd673d01766205f529a2025 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjg0OjJBOThBOkZCRDI4OjEzRDFGQjo2QjAxRkUzNyIsInZpc2l0b3JfaWQiOiI5ODcwMjk5MDIxMjc2NjA1OTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0073427a095e886456ab6265fb803238ad1fbe20d1d2301dba18782e3537d832 |
| hovercard-subject-tag | pull_request:5138800102 |
| 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/9629/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 Consolidate the bisect bounds/callback work and #9630's insort result-disposal fix. Request sequence length only for an omitted, None, or -1 upper bound. Snapshot the sequence item slo... |
| 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