René's URL Explorer Experiment


Title: Weakref callback by BenLewis-Seequent · Pull Request #488 · RustPython/RustPython · GitHub

Open Graph Title: Weakref callback by BenLewis-Seequent · Pull Request #488 · RustPython/RustPython

X Title: Weakref callback by BenLewis-Seequent · Pull Request #488 · RustPython/RustPython

Description: I have made changes to allow weak references to have callbacks, but I have ran into a problem about how to run these callbacks during drop as we have no reference in the virual machine within the drop method. I see three possible solutions to this: Add PyObjectRef::drop(vm: &mut VirtualMachine, obj: PyObjectRef) which would have be called to drop each reference. There is no way to make the compiler enforce this, so this could lead to plenty of bugs caused by not being dropped correctly. Make it possible to invoke Python code without having to be passed a mutable reference to the virtual machine. This would likely involve making fine locks for the parts of the virtual machine that needs to be locked. This is effectively 'Remove GIL'. Don't immediately invoke the callbacks/__del__ and do it later: Either when control returns to the core interpreter Or don't use reference counting at all, instead use a mark and sweep GC which can be given the mutable reference to the virtual machine when we want to collect garbage.

Open Graph Description: I have made changes to allow weak references to have callbacks, but I have ran into a problem about how to run these callbacks during drop as we have no reference in the virual machine within the d...

X Description: I have made changes to allow weak references to have callbacks, but I have ran into a problem about how to run these callbacks during drop as we have no reference in the virual machine within the d...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:8b54ce6b-ba35-4d47-02f7-5c7fbe3db694
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA3FA:1A29F8:17D96A4:20290A2:6A596C5A
html-safe-nonce979cab933c16092a873327d5d86fcd1fb0cec43de7fb57aad81a9078a54d9cff
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0ZBOjFBMjlGODoxN0Q5NkE0OjIwMjkwQTI6NkE1OTZDNUEiLCJ2aXNpdG9yX2lkIjoiNjcwMjg1NDUzODA2MjgxODM5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacb9dc2d27d9536566dfbf907fea9602c6bd972e713ce75c8bebd4d0edab230831
hovercard-subject-tagpull_request:253679022
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/488/files
twitter:imagehttps://avatars.githubusercontent.com/u/7391596?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/7391596?s=400&v=4
og:image:altI have made changes to allow weak references to have callbacks, but I have ran into a problem about how to run these callbacks during drop as we have no reference in the virual machine within the d...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonea540949572872b935b393b36db38922db390ae71c859537d741b8f3eb7e545b5
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
release624bb50a7497aa346bef8cc3743af408a9ea10ca
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/488/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F488%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F488%2Ffiles
Sign up https://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/488/files
Reloadhttps://github.com/RustPython/RustPython/pull/488/files
Reloadhttps://github.com/RustPython/RustPython/pull/488/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/488/files
RustPython https://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Notifications https://github.com/login?return_to=%2FRustPython%2FRustPython
Fork 1.5k https://github.com/login?return_to=%2FRustPython%2FRustPython
Star 22.2k https://github.com/login?return_to=%2FRustPython%2FRustPython
Code https://github.com/RustPython/RustPython
Issues 287 https://github.com/RustPython/RustPython/issues
Pull requests 104 https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality 0 https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
Code https://github.com/RustPython/RustPython
Issues https://github.com/RustPython/RustPython/issues
Pull requests https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
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
BenLewis-Seequenthttps://github.com/BenLewis-Seequent
RustPython:masterhttps://github.com/RustPython/RustPython/tree/master
BenLewis-Seequent:weakref_callbackhttps://github.com/BenLewis-Seequent/RustPython/tree/weakref_callback
Conversation 9 https://github.com/RustPython/RustPython/pull/488
Commits 10 https://github.com/RustPython/RustPython/pull/488/commits
Checks 0 https://github.com/RustPython/RustPython/pull/488/checks
Files changed https://github.com/RustPython/RustPython/pull/488/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/488/files
Weakref callback https://github.com/RustPython/RustPython/pull/488/files#top
Show all changes 10 commits https://github.com/RustPython/RustPython/pull/488/files
8dd5810 Make PyObjectRef and PyObjectWeakRef it's own type. skinnyBat Feb 13, 2019 https://github.com/RustPython/RustPython/pull/488/commits/8dd58108485224bce8eeb672ad77468add7510f5
0c1bee9 Move weakref type to obj folder, as it's a core type and needs to be skinnyBat Feb 16, 2019 https://github.com/RustPython/RustPython/pull/488/commits/0c1bee994627f9af3dce46f03532397a0779ccb5
eab6e2f Add callback to object being reference. skinnyBat Feb 17, 2019 https://github.com/RustPython/RustPython/pull/488/commits/eab6e2f3b2bfe27c773c9c45426cb22fc3ac2d33
6a13a83 Merge branch 'master' into weakref_callback skinnyBat Feb 18, 2019 https://github.com/RustPython/RustPython/pull/488/commits/6a13a83e2d3de0888526aabefb7c0c60e4520b23
4355105 Queue up objects to be deleted to allow for weakref callbacks skinnyBat Feb 19, 2019 https://github.com/RustPython/RustPython/pull/488/commits/435510570cfd5559a8de4d35117354c0f4f87294
195a56a Add more tests for weakref and fix objects not holding there weak skinnyBat Feb 19, 2019 https://github.com/RustPython/RustPython/pull/488/commits/195a56a66b67f117471057589872ab407f72703f
80c72d0 Merge branch 'master' into weakref_callback skinnyBat Feb 19, 2019 https://github.com/RustPython/RustPython/pull/488/commits/80c72d0f6ef75411a7f423c013c0b403666327ef
e89f8fa Fix clippy warning skinnyBat Feb 19, 2019 https://github.com/RustPython/RustPython/pull/488/commits/e89f8fafe55082143b231b79098d0643e2b1c82c
b6d28cf Formatting skinnyBat Feb 19, 2019 https://github.com/RustPython/RustPython/pull/488/commits/b6d28cf425de8dd68a6bb12f7dfdea3ee300dc17
350bc30 Move weak_refs attribute into Instance payload skinnyBat Feb 20, 2019 https://github.com/RustPython/RustPython/pull/488/commits/350bc30311ef76fcbcfaf34a3521edd5c71eaa34
Clear filters https://github.com/RustPython/RustPython/pull/488/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/488/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/488/files
weakrefs.py https://github.com/RustPython/RustPython/pull/488/files#diff-1f79d2f60188b8d87e9d16e8d3c634f4515beffaa4ea3b6930ad649e1de90f52
builtins.rs https://github.com/RustPython/RustPython/pull/488/files#diff-2fb46e28bfa853775da229c10cd0c32c3b093d30bf4ff26abaa6caeac035ea00
frame.rs https://github.com/RustPython/RustPython/pull/488/files#diff-b12bfe4c8654c4d3a81839ecf8fe1e9f41a1bac245ef944a0e3d8639a252ad15
mod.rs https://github.com/RustPython/RustPython/pull/488/files#diff-cb3f6c41256bb969446b58293c3ac50ccca42261ef0b04671401eec0ed8c1bde
objstr.rs https://github.com/RustPython/RustPython/pull/488/files#diff-5959b66a45a435519c5d9ab11fd775670a67b19cb079f0025a673c87849da0ea
objtype.rs https://github.com/RustPython/RustPython/pull/488/files#diff-46a1291f828c8e7ed91d6c0f019c80b93cd33405254b258cf89cfc2f53d7f2b5
objweakref.rs https://github.com/RustPython/RustPython/pull/488/files#diff-a276a0ac998c01613d6cdb5687babdb77cde8a56502cf2a5527ac4ada3452b40
pyobject.rs https://github.com/RustPython/RustPython/pull/488/files#diff-84524dac95852f23d03df0b427c833911eb825066c10e1bbeac03a99db0d5caa
weakref.rs https://github.com/RustPython/RustPython/pull/488/files#diff-e53b406e90801c6b61a5ee6c3aff4d1218bb364b5d343f1dda92a1643567705c
sysmodule.rs https://github.com/RustPython/RustPython/pull/488/files#diff-7ad0f3f4e1f2215afb4494dc68b35d8591a499c318f1618cec56aecee0fbdc4a
tests/snippets/weakrefs.pyhttps://github.com/RustPython/RustPython/pull/488/files#diff-1f79d2f60188b8d87e9d16e8d3c634f4515beffaa4ea3b6930ad649e1de90f52
View file https://github.com/BenLewis-Seequent/RustPython/blob/350bc30311ef76fcbcfaf34a3521edd5c71eaa34/tests/snippets/weakrefs.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/488/{{ revealButtonHref }}
vm/src/builtins.rshttps://github.com/RustPython/RustPython/pull/488/files#diff-2fb46e28bfa853775da229c10cd0c32c3b093d30bf4ff26abaa6caeac035ea00
View file https://github.com/BenLewis-Seequent/RustPython/blob/350bc30311ef76fcbcfaf34a3521edd5c71eaa34/vm/src/builtins.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/488/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/488/files#diff-2fb46e28bfa853775da229c10cd0c32c3b093d30bf4ff26abaa6caeac035ea00
https://github.com/RustPython/RustPython/pull/488/files#diff-2fb46e28bfa853775da229c10cd0c32c3b093d30bf4ff26abaa6caeac035ea00
https://github.com/RustPython/RustPython/pull/488/files#diff-2fb46e28bfa853775da229c10cd0c32c3b093d30bf4ff26abaa6caeac035ea00
https://github.com/RustPython/RustPython/pull/488/files#diff-2fb46e28bfa853775da229c10cd0c32c3b093d30bf4ff26abaa6caeac035ea00
vm/src/frame.rshttps://github.com/RustPython/RustPython/pull/488/files#diff-b12bfe4c8654c4d3a81839ecf8fe1e9f41a1bac245ef944a0e3d8639a252ad15
View file https://github.com/BenLewis-Seequent/RustPython/blob/350bc30311ef76fcbcfaf34a3521edd5c71eaa34/vm/src/frame.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/488/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/488/files#diff-b12bfe4c8654c4d3a81839ecf8fe1e9f41a1bac245ef944a0e3d8639a252ad15
https://github.com/RustPython/RustPython/pull/488/files#diff-b12bfe4c8654c4d3a81839ecf8fe1e9f41a1bac245ef944a0e3d8639a252ad15
https://github.com/RustPython/RustPython/pull/488/files#diff-b12bfe4c8654c4d3a81839ecf8fe1e9f41a1bac245ef944a0e3d8639a252ad15
https://github.com/RustPython/RustPython/pull/488/files#diff-b12bfe4c8654c4d3a81839ecf8fe1e9f41a1bac245ef944a0e3d8639a252ad15
vm/src/obj/mod.rshttps://github.com/RustPython/RustPython/pull/488/files#diff-cb3f6c41256bb969446b58293c3ac50ccca42261ef0b04671401eec0ed8c1bde
View file https://github.com/BenLewis-Seequent/RustPython/blob/350bc30311ef76fcbcfaf34a3521edd5c71eaa34/vm/src/obj/mod.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/488/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/488/files#diff-cb3f6c41256bb969446b58293c3ac50ccca42261ef0b04671401eec0ed8c1bde
vm/src/obj/objstr.rshttps://github.com/RustPython/RustPython/pull/488/files#diff-5959b66a45a435519c5d9ab11fd775670a67b19cb079f0025a673c87849da0ea
View file https://github.com/BenLewis-Seequent/RustPython/blob/350bc30311ef76fcbcfaf34a3521edd5c71eaa34/vm/src/obj/objstr.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/488/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/488/files#diff-5959b66a45a435519c5d9ab11fd775670a67b19cb079f0025a673c87849da0ea
https://github.com/RustPython/RustPython/pull/488/files#diff-5959b66a45a435519c5d9ab11fd775670a67b19cb079f0025a673c87849da0ea
https://github.com/RustPython/RustPython/pull/488/files#diff-5959b66a45a435519c5d9ab11fd775670a67b19cb079f0025a673c87849da0ea
vm/src/obj/objtype.rshttps://github.com/RustPython/RustPython/pull/488/files#diff-46a1291f828c8e7ed91d6c0f019c80b93cd33405254b258cf89cfc2f53d7f2b5
View file https://github.com/BenLewis-Seequent/RustPython/blob/350bc30311ef76fcbcfaf34a3521edd5c71eaa34/vm/src/obj/objtype.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/488/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/488/files#diff-46a1291f828c8e7ed91d6c0f019c80b93cd33405254b258cf89cfc2f53d7f2b5
https://github.com/RustPython/RustPython/pull/488/files#diff-46a1291f828c8e7ed91d6c0f019c80b93cd33405254b258cf89cfc2f53d7f2b5
vm/src/obj/objweakref.rshttps://github.com/RustPython/RustPython/pull/488/files#diff-a276a0ac998c01613d6cdb5687babdb77cde8a56502cf2a5527ac4ada3452b40
View file https://github.com/BenLewis-Seequent/RustPython/blob/350bc30311ef76fcbcfaf34a3521edd5c71eaa34/vm/src/obj/objweakref.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/488/{{ revealButtonHref }}
Please reload this pagehttps://github.com/RustPython/RustPython/pull/488/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.