René's URL Explorer Experiment


Title: Unify PyObjectRef ownership with PyRef by youknowdot · Pull Request #9080 · RustPython/RustPython · GitHub

Open Graph Title: Unify PyObjectRef ownership with PyRef by youknowdot · Pull Request #9080 · RustPython/RustPython

X Title: Unify PyObjectRef ownership with PyRef by youknowdot · Pull Request #9080 · RustPython/RustPython

Description: Summary Make PyObjectRef an alias of PyRef, sharing ownership, clone/drop, raw transfers, weakref integration and C-API conversions while retaining typed payload projection. Remove the private AnySet alias and use PyRef consistently for owners. PyAnySet is the borrowed view. Registration remains sealed; no public unsafe extension API is added, and user-defined unions are deferred to a future interface. Extend the sealed borrowed-target model to an internal PyAnySet view and PyRef owner. Checked conversion accepts set/frozenset subclasses only when their native payload matches; each payload access downcasts the actual alternative. It never assumes that set and frozenset payload layouts are interchangeable. Support mixed set/frozenset typed tuples through a non-erased typed-element marker. Preserve the public PyTuple> API with identical erased storage in every view, invariant type markers and checked typed slices. Nested typed construction/borrowing/erasure works; this does not add recursive checking of arbitrary nested untyped tuples. Preserve exact nonempty tuple identity for normalized full slices through borrowed-to-owned conversion. Empty slices retain canonicalization, subclass slices remain plain tuples, and custom indices are converted once. Integrate ownership documentation into the existing public object module. ArgIterable remains a wrapper because it also stores a cached iterator function. Ownership and representation Union views are transparent over the erased object header, not fictional Py payloads. Typed tuples always physically contain erased reference storage; typed slice casts reinterpret only transparent reference elements whose invariants are already established. Vector transfers use raw parts and preserve allocation, capacity and exactly-once ownership. Existing allocation vtables, GC traversal and destruction remain erased. The tests cover successful and rejected conversion, borrowed ownership, refcounts, aliasing, nested views and exact-once destruction. Rust API considerations Unqualified PyRef::from_raw can require an explicit type parameter. Generic typed-view code can need a PyRefTarget> bound. Rust Debug consistently uses the allocation's vtable. These source and diagnostic changes are intentional. No performance claim is made. Validation Current head 87737558e9bdf7db6618f00fcdf05663db78aed5: CI and CodSpeed are pending; pyperformance is skipped. At the owner's inline review request, both added Python reference-snippet files are removed completely. The added threaded clone/drop stress test is removed, and two overlapping Rust tuple ownership tests are consolidated while preserving both distinct vector-transfer constructors. Existing main tests and production behavior are unchanged by this cleanup. Fresh VM library test compilation, seven exact ordinary ownership tests, affected VM library/test strict Clippy (encodings,threading, -D warnings) and normal repository hooks passed. The seven cases retain layout, raw transfer/downcast, both union alternatives, typed-tuple composition, failed-conversion ownership and exactly-once-drop coverage. This test-only checkpoint uses source tree c4e01b916f3404bc8235d3a03df96fcddd544b8e and VM harness SHA256 9cc925004792a74cb80d1d914aee1e5fd0eee08737de4b43208a5cb1f4a66445. The preceding alias-removal head 2a9d012e80a9f0c1dc1bd79503d5475fae34bfff passed all 25 hosted CI jobs and CodSpeed after one retry of a Windows Rust job that failed during a rustup network download before compilation. Its exact CI-feature strict Clippy (capi,encodings,jit,sqlite,threading, including bins/examples/tests) passed locally. Earlier implementation checkpoints passed 219 reviewed ordinary workspace Rust tests, 11 ordinary C-API tests, six native Python snippets, two exact pytest cases, one sealed-target compile-fail doctest and ordinary public rustdoc generation. The two subsequently removed snippets also passed pinned CPython d220409a13b77de7a6c30abe16ea90db01528edc. These remain historical validation records; the deleted files are not reintroduced. The broader earlier native checkpoint used tree fc3a59f42b0d8fffdea569de520df630d2474da4 and CLI SHA256 863a130e5d8a3bf940381ebb65558fbdbefdc3acd8f489d327211af6b2d9eee7. The later alias checkpoint used production tree 80f740adf2b0b09f7a76304a4a75abf598e9c4cc and CLI SHA256 bf9d136132e3cd3ff795385933a05a6a22e9cca90c769d56fc1f53ba7ea9aa3b. Both binaries retain the embedded 4fbb4f3-dirty build-script stamp; exact source trees and artifact hashes establish their provenance. The final cleanup rebuilds the affected test harness only. The local runtime scope is a reviewed subset, not a claim that the complete workspace or Python suites ran. Extreme allocation, malformed construction, process-memory, thread/race stress and other unreviewed cases were left out; the existing complete tuple snippet was not run because it contains an extreme-size repetition case. Bundled Lib/ is unchanged. Warnings-denied rustdoc encounters six warnings already present in the old PR source (private links, a stale link and an unquoted generic type). Source comparison and the failed strict run are retained; ordinary rustdoc succeeds and the integrated documentation adds no diagnostic. No test assertion was weakened or marked as an expected failure. AI assistance This PR follows the project's AI policy. Implementation, investigation and validation were assisted by OpenAI Codex; the exact model identifier was not exposed by the environment. The commit includes the repository-required assistance trailer. Summary by CodeRabbit Bug Fixes Set and frozenset operations now handle subclasses more consistently, including in-place operations and overridden iteration. Tuple slicing preserves the original object when a full slice is requested on an exact tuple. Slice indices are evaluated only once. Set and tuple iterators retain referenced objects for as long as needed, preventing premature cleanup.

Open Graph Description: Summary Make PyObjectRef an alias of PyRef<PyObject>, sharing ownership, clone/drop, raw transfers, weakref integration and C-API conversions while retaining typed payload projection. Remove...

X Description: Summary Make PyObjectRef an alias of PyRef&lt;PyObject&gt;, sharing ownership, clone/drop, raw transfers, weakref integration and C-API conversions while retaining typed payload projection...

Opengraph URL: https://github.com/RustPython/RustPython/pull/9080

X: @github

direct link

Domain: github.com

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/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:3b57c84e-9e41-0323-0423-5ae0ef587e7e
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA6B0:A71F9:3075EE8:3D5A89C:6B01FE39
html-safe-nonce9cb2dc122008ddfb20968ad768577aeda6224a4b483ba743e89e2bee14cca40a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNkIwOkE3MUY5OjMwNzVFRTg6M0Q1QTg5Qzo2QjAxRkUzOSIsInZpc2l0b3JfaWQiOiIxOTcyNTUwNzc0MjkwNTEzNDY1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac607ef30894d623dddfd2340227166f41c222793e8859f2beac64f23ea48122f2
hovercard-subject-tagpull_request:4813421257
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/9080/files
twitter:imagehttps://avatars.githubusercontent.com/u/336763669?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/336763669?s=400&v=4
og:image:altSummary Make PyObjectRef an alias of PyRef<PyObject>, sharing ownership, clone/drop, raw transfers, weakref integration and C-API conversions while retaining typed payload projection. Remove...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/9080/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F9080%2Ffiles
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%2Fpull%2F9080%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/pull/9080/files
Reloadhttps://github.com/RustPython/RustPython/pull/9080/files
Reloadhttps://github.com/RustPython/RustPython/pull/9080/files
RustPythonhttps://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Codehttps://github.com/RustPython/RustPython
Issues195 (195)https://github.com/RustPython/RustPython/issues
Pull requests133 (133)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
Sign up for GitHub https://github.com/signup?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
youknowonehttps://github.com/youknowone
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
youknowdot:refactor/pyref-pyobjecthttps://github.com/youknowdot/RustPython/tree/refactor/pyref-pyobject
Conversation 11 https://github.com/RustPython/RustPython/pull/9080
Commits 1 https://github.com/RustPython/RustPython/pull/9080/commits
Checks 29 https://github.com/RustPython/RustPython/pull/9080/checks
Files changed https://github.com/RustPython/RustPython/pull/9080/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9080/files
Unify PyObjectRef ownership with PyRef https://github.com/RustPython/RustPython/pull/9080/files#top
Show all changes 1 commit https://github.com/RustPython/RustPython/pull/9080/files
8773755 Unify PyObjectRef ownership with extensible PyRef views youknowdot Oct 10, 2026 https://github.com/RustPython/RustPython/pull/9080/commits/87737558e9bdf7db6618f00fcdf05663db78aed5
Clear filters https://github.com/RustPython/RustPython/pull/9080/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9080/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9080/files
Cargo.lock https://github.com/RustPython/RustPython/pull/9080/files#diff-13ee4b2252c9e516a0547f2891aa2105c3ca71c6d7a1e682c69be97998dfc87e
Cargo.toml https://github.com/RustPython/RustPython/pull/9080/files#diff-04e7273787823f2ad763529941d68221727daa79c8aefa830c91280732e2f2d6
pyerrors.rs https://github.com/RustPython/RustPython/pull/9080/files#diff-182ff1f3912ef23ede35e910440a570c251f3a564eef94cf5ca876939b3ca81d
util.rs https://github.com/RustPython/RustPython/pull/9080/files#diff-853d32ddc8c3e49303b0d62040d07d6197a113b14e9e0fb3879fb87ac4dcebbd
_sqlite3.rs https://github.com/RustPython/RustPython/pull/9080/files#diff-5a5ea8fc8d5bfc6b5da126f9574990e39802662762f23a2a6a9143beca021e15
descriptor.rs https://github.com/RustPython/RustPython/pull/9080/files#diff-7c8850ad317bf0c33b339610ec3e80a4038cd37545ba20746f8e680d87931b8e
frame_locals_proxy.rs https://github.com/RustPython/RustPython/pull/9080/files#diff-ee980e75c38cd229491c633673c91416e4968f7c269de8d42d6a3e1b71a3083e
set.rs https://github.com/RustPython/RustPython/pull/9080/files#diff-ca3250b43726cb4327f8b4f6d413151036abc2f00f7c3197f55432013ca2c07f
tuple.rs https://github.com/RustPython/RustPython/pull/9080/files#diff-606274a9a62c77c00f802fbc298be35b47e2932cf90cc413748b4d8fc69d7c7e
core.rs https://github.com/RustPython/RustPython/pull/9080/files#diff-29e5bc70b379859cc90757773e821848e53dff65ce99167408b6f547bc317196
ext.rs https://github.com/RustPython/RustPython/pull/9080/files#diff-ccab52adc1059b887873204f5691f9782da457688e788cfa7b214961357e11fa
mod.rs https://github.com/RustPython/RustPython/pull/9080/files#diff-97e64e96821f94d35a99188a63905688e41b2334884261f3330d71f3dce4dae9
Cargo.lockhttps://github.com/RustPython/RustPython/pull/9080/files#diff-13ee4b2252c9e516a0547f2891aa2105c3ca71c6d7a1e682c69be97998dfc87e
View file https://github.com/youknowdot/RustPython/blob/87737558e9bdf7db6618f00fcdf05663db78aed5/Cargo.lock
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9080/files
crates/capi/Cargo.tomlhttps://github.com/RustPython/RustPython/pull/9080/files#diff-04e7273787823f2ad763529941d68221727daa79c8aefa830c91280732e2f2d6
View file https://github.com/youknowdot/RustPython/blob/87737558e9bdf7db6618f00fcdf05663db78aed5/crates/capi/Cargo.toml
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9080/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9080/files#diff-04e7273787823f2ad763529941d68221727daa79c8aefa830c91280732e2f2d6
https://github.com/RustPython/RustPython/pull/9080/files#diff-04e7273787823f2ad763529941d68221727daa79c8aefa830c91280732e2f2d6
crates/capi/src/pyerrors.rshttps://github.com/RustPython/RustPython/pull/9080/files#diff-182ff1f3912ef23ede35e910440a570c251f3a564eef94cf5ca876939b3ca81d
View file https://github.com/youknowdot/RustPython/blob/87737558e9bdf7db6618f00fcdf05663db78aed5/crates/capi/src/pyerrors.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9080/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9080/files#diff-182ff1f3912ef23ede35e910440a570c251f3a564eef94cf5ca876939b3ca81d
https://github.com/RustPython/RustPython/pull/9080/files#diff-182ff1f3912ef23ede35e910440a570c251f3a564eef94cf5ca876939b3ca81d
crates/capi/src/util.rshttps://github.com/RustPython/RustPython/pull/9080/files#diff-853d32ddc8c3e49303b0d62040d07d6197a113b14e9e0fb3879fb87ac4dcebbd
View file https://github.com/youknowdot/RustPython/blob/87737558e9bdf7db6618f00fcdf05663db78aed5/crates/capi/src/util.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9080/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9080/files#diff-853d32ddc8c3e49303b0d62040d07d6197a113b14e9e0fb3879fb87ac4dcebbd
https://github.com/RustPython/RustPython/pull/9080/files#diff-853d32ddc8c3e49303b0d62040d07d6197a113b14e9e0fb3879fb87ac4dcebbd
https://github.com/RustPython/RustPython/pull/9080/files#diff-853d32ddc8c3e49303b0d62040d07d6197a113b14e9e0fb3879fb87ac4dcebbd
https://github.com/RustPython/RustPython/pull/9080/files#diff-853d32ddc8c3e49303b0d62040d07d6197a113b14e9e0fb3879fb87ac4dcebbd
https://github.com/RustPython/RustPython/pull/9080/files#diff-853d32ddc8c3e49303b0d62040d07d6197a113b14e9e0fb3879fb87ac4dcebbd
https://github.com/RustPython/RustPython/pull/9080/files#diff-853d32ddc8c3e49303b0d62040d07d6197a113b14e9e0fb3879fb87ac4dcebbd
crates/stdlib/src/_sqlite3.rshttps://github.com/RustPython/RustPython/pull/9080/files#diff-5a5ea8fc8d5bfc6b5da126f9574990e39802662762f23a2a6a9143beca021e15
View file https://github.com/youknowdot/RustPython/blob/87737558e9bdf7db6618f00fcdf05663db78aed5/crates/stdlib/src/_sqlite3.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9080/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9080/files#diff-5a5ea8fc8d5bfc6b5da126f9574990e39802662762f23a2a6a9143beca021e15
https://github.com/RustPython/RustPython/pull/9080/files#diff-5a5ea8fc8d5bfc6b5da126f9574990e39802662762f23a2a6a9143beca021e15
crates/vm/src/builtins/descriptor.rshttps://github.com/RustPython/RustPython/pull/9080/files#diff-7c8850ad317bf0c33b339610ec3e80a4038cd37545ba20746f8e680d87931b8e
View file https://github.com/youknowdot/RustPython/blob/87737558e9bdf7db6618f00fcdf05663db78aed5/crates/vm/src/builtins/descriptor.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9080/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9080/files#diff-7c8850ad317bf0c33b339610ec3e80a4038cd37545ba20746f8e680d87931b8e
https://github.com/RustPython/RustPython/pull/9080/files#diff-7c8850ad317bf0c33b339610ec3e80a4038cd37545ba20746f8e680d87931b8e
crates/vm/src/builtins/frame_locals_proxy.rshttps://github.com/RustPython/RustPython/pull/9080/files#diff-ee980e75c38cd229491c633673c91416e4968f7c269de8d42d6a3e1b71a3083e
View file https://github.com/youknowdot/RustPython/blob/87737558e9bdf7db6618f00fcdf05663db78aed5/crates/vm/src/builtins/frame_locals_proxy.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9080/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9080/files#diff-ee980e75c38cd229491c633673c91416e4968f7c269de8d42d6a3e1b71a3083e
https://github.com/RustPython/RustPython/pull/9080/files#diff-ee980e75c38cd229491c633673c91416e4968f7c269de8d42d6a3e1b71a3083e
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9080/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9080/files
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.