René's URL Explorer Experiment


Title: Preserve ctypes element views and their references by 1ndahous3 · Pull Request #9229 · RustPython/RustPython · GitHub

Open Graph Title: Preserve ctypes element views and their references by 1ndahous3 · Pull Request #9229 · RustPython/RustPython

X Title: Preserve ctypes element views and their references by 1ndahous3 · Pull Request #9229 · RustPython/RustPython

Description: Found while testing Scapy 2.8.0 route discovery on Windows. Summary Return typed views for compound array and pointer elements, including simple-type subclasses and function pointers. Preserve scalar results and byte order for generated endian types. Apply endian metaclass conversion to Structure fields declared in the class body. Keep generated endian types as siblings and reject incompatible ctypes field values; copy compatible instances without swapping their encoded bytes again. Preserve the owner and array length for indexed views and pointer.contents; scalar pointer assignments and pointer-view contents replacement write through to the element's storage. Retain callback thunks and references from the root owner when copying views. Resolve py_object values through retained owners, using direct retention keys for common indexed reads before searching the owner graph. Use the full nesting path for reference keys so sibling elements do not release each other's pointees. Snapshot source bytes before copying pointer elements so self-assignment and overlapping views are safe. Run array element conversions and reference finalizers outside storage and ownership locks. Commit pointer bytes and visible/private owners before releasing replaced references, preserving assignments made by reentrant finalizers. Performance Compared with the previous PR revision (cb3ec5312), release builds. Full indexed scan of 2,048 py_object elements, median of three runs: Platform Before After Speedup Windows 11 x64 93.88 ms 0.99 ms ~95x Linux x86_64 94.58 ms 1.03 ms ~92x Native c_uint32 fields, compared with f23e581c9 (median of five runs): Operation Platform Before After Speedup Read Windows 11 x64 1.14 µs 0.32 µs ~3.5x Read Linux x86_64 1.08 µs 0.29 µs ~3.8x Assign number Windows 11 x64 1.16 µs 0.33 µs ~3.5x Assign number Linux x86_64 1.07 µs 0.28 µs ~3.9x Assign ctypes instance Windows 11 x64 1.35 µs 0.56 µs ~2.4x Assign ctypes instance Linux x86_64 1.28 µs 0.49 µs ~2.6x AI assistance This PR follows our AI policy. Written with Codex (GPT-6), reviewed by a human before submission. Summary by CodeRabbit Bug Fixes Fixed ctypes array element reads and pointer contents so returned views retain their owners, and writes update the correct memory. Improved reference retention for character pointers, callbacks, nested pointers, and copied or replaced values. Fixed indexing and assignment for compound types, object pointers, and byte-swapped values. Improved handling of null object pointers and reference cleanup during updates. Fixed pointer-backed scalar assignments and retrieval of Python objects stored in ctypes values. Improved safety when finalizers run during callback and byte-pointer updates. Fixed ctypes structure field initialization and endian-specific value handling.

Open Graph Description: Found while testing Scapy 2.8.0 route discovery on Windows. Summary Return typed views for compound array and pointer elements, including simple-type subclasses and function pointers. Preserve sca...

X Description: Found while testing Scapy 2.8.0 route discovery on Windows. Summary Return typed views for compound array and pointer elements, including simple-type subclasses and function pointers. Preserve sca...

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

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:e3cc2a92-c356-2fbd-aea2-5e1215b1a678
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBF82:31D532:10EB22A:167E145:6B01E40C
html-safe-noncecac4462d1af1e20d2e8d79c3986881b6092904b3eeeac3a74e275994d4d1e4b5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjgyOjMxRDUzMjoxMEVCMjJBOjE2N0UxNDU6NkIwMUU0MEMiLCJ2aXNpdG9yX2lkIjoiNDQ5NjEwNDQxMzAxODA1NTY5MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacce1bfa3f5fc2097a1e44b5c810f2ffc920487dcda97a240534b273672de8a8ca
hovercard-subject-tagpull_request:4925434074
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/9229/files
twitter:imagehttps://avatars.githubusercontent.com/u/9205230?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/9205230?s=400&v=4
og:image:altFound while testing Scapy 2.8.0 route discovery on Windows. Summary Return typed views for compound array and pointer elements, including simple-type subclasses and function pointers. Preserve sca...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/9229/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F9229%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%2F9229%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/9229/files
Reloadhttps://github.com/RustPython/RustPython/pull/9229/files
Reloadhttps://github.com/RustPython/RustPython/pull/9229/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
1ndahous3:ctypes_aggregate_indexhttps://github.com/1ndahous3/RustPython/tree/ctypes_aggregate_index
Conversation 47 https://github.com/RustPython/RustPython/pull/9229
Commits 6 https://github.com/RustPython/RustPython/pull/9229/commits
Checks 28 https://github.com/RustPython/RustPython/pull/9229/checks
Files changed https://github.com/RustPython/RustPython/pull/9229/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9229/files
Preserve ctypes element views and their references https://github.com/RustPython/RustPython/pull/9229/files#top
Show all changes 6 commits https://github.com/RustPython/RustPython/pull/9229/files
4a82ab6 Preserve ctypes element views and their references 1ndahous3 Oct 19, 2026 https://github.com/RustPython/RustPython/pull/9229/commits/4a82ab680c65cff762033537776bf68184aeea53
cb3ec53 Fix ctypes reentrant ownership and scalar view handling 1ndahous3 Oct 19, 2026 https://github.com/RustPython/RustPython/pull/9229/commits/cb3ec53126af190a76a2c53464ab0773539e9982
d65ee31 Fix ctypes pointer view writes and indexed object lookup 1ndahous3 Oct 19, 2026 https://github.com/RustPython/RustPython/pull/9229/commits/d65ee314ea1a67f44c5d78289f3df08d97d88afe
f23e581 Fix ctypes field byte order and encoded instance copies 1ndahous3 Oct 19, 2026 https://github.com/RustPython/RustPython/pull/9229/commits/f23e581c9d1a3c9fc4b7f18b8202ccd2791fd7e7
6dd75f6 Fix ctypes effective field types and overlapping pointer copies 1ndahous3 Oct 20, 2026 https://github.com/RustPython/RustPython/pull/9229/commits/6dd75f658c1ae9db70ccd2dd8ba7976b0be170d0
ea2c45e Reject arrays for incomplete ctypes pointer fields 1ndahous3 Oct 20, 2026 https://github.com/RustPython/RustPython/pull/9229/commits/ea2c45efc262fd35a94eaee17ef1471d1728b3ab
Clear filters https://github.com/RustPython/RustPython/pull/9229/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9229/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9229/files
array.rs https://github.com/RustPython/RustPython/pull/9229/files#diff-1e6ef8a4a7706885a4b2f08152c3a0298bf0db75e092d52708b08caa6726d321
base.rs https://github.com/RustPython/RustPython/pull/9229/files#diff-16c64cd355bd8034d61677ad8e407239d548e0e35c48ee05e951e03e93aa1781
function.rs https://github.com/RustPython/RustPython/pull/9229/files#diff-d4cf72f95963a6d3e08f9e7e53594d6b5e2cc7711afbc0b490894d97dc8d8648
pointer.rs https://github.com/RustPython/RustPython/pull/9229/files#diff-31a7efabe21a7be0f4dcee8c644af456ac58989d1c551faf515841b41e652a66
simple.rs https://github.com/RustPython/RustPython/pull/9229/files#diff-640c11bed665f401309f30eaa8f59ef7ca4c930c57bc97dbf036e19030e1e64a
structure.rs https://github.com/RustPython/RustPython/pull/9229/files#diff-694b74e6249e2ecc75f0c09aec5f2dcfb83e5d4d33eb5a03fced0fdac480eb50
stdlib_ctypes.py https://github.com/RustPython/RustPython/pull/9229/files#diff-7cfa080a4c0c0eac19bf2bd0eea152938488bab4c8a8d1b1d7bbc14bce41a61c
crates/vm/src/stdlib/_ctypes/array.rshttps://github.com/RustPython/RustPython/pull/9229/files#diff-1e6ef8a4a7706885a4b2f08152c3a0298bf0db75e092d52708b08caa6726d321
View file https://github.com/1ndahous3/RustPython/blob/ea2c45efc262fd35a94eaee17ef1471d1728b3ab/crates/vm/src/stdlib/_ctypes/array.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9229/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9229/files#diff-1e6ef8a4a7706885a4b2f08152c3a0298bf0db75e092d52708b08caa6726d321
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9229/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9229/files
https://github.com/RustPython/RustPython/pull/9229/files#diff-1e6ef8a4a7706885a4b2f08152c3a0298bf0db75e092d52708b08caa6726d321
https://github.com/RustPython/RustPython/pull/9229/files#diff-1e6ef8a4a7706885a4b2f08152c3a0298bf0db75e092d52708b08caa6726d321
https://github.com/RustPython/RustPython/pull/9229/files#diff-1e6ef8a4a7706885a4b2f08152c3a0298bf0db75e092d52708b08caa6726d321
https://github.com/RustPython/RustPython/pull/9229/files#diff-1e6ef8a4a7706885a4b2f08152c3a0298bf0db75e092d52708b08caa6726d321
https://github.com/RustPython/RustPython/pull/9229/files#diff-1e6ef8a4a7706885a4b2f08152c3a0298bf0db75e092d52708b08caa6726d321
https://github.com/RustPython/RustPython/pull/9229/files#diff-1e6ef8a4a7706885a4b2f08152c3a0298bf0db75e092d52708b08caa6726d321
https://github.com/RustPython/RustPython/pull/9229/files#diff-1e6ef8a4a7706885a4b2f08152c3a0298bf0db75e092d52708b08caa6726d321
https://github.com/RustPython/RustPython/pull/9229/files#diff-1e6ef8a4a7706885a4b2f08152c3a0298bf0db75e092d52708b08caa6726d321
https://github.com/RustPython/RustPython/pull/9229/files#diff-1e6ef8a4a7706885a4b2f08152c3a0298bf0db75e092d52708b08caa6726d321
https://github.com/RustPython/RustPython/pull/9229/files#diff-1e6ef8a4a7706885a4b2f08152c3a0298bf0db75e092d52708b08caa6726d321
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9229/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9229/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.