-
-
Notifications
You must be signed in to change notification settings - Fork 3k
feat(mypyc): proper weakref support #19056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BobTheBuidler
wants to merge
23
commits into
python:master
Choose a base branch
from
BobTheBuidler:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
1f4a3a0
feat: proper weakref support
BobTheBuidler afbefea
Update emitclass.py
BobTheBuidler 1a166d4
Update class_ir.py
BobTheBuidler 65fa594
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e8d9394
Update emitclass.py
BobTheBuidler 887bc39
Update emitclass.py
BobTheBuidler 85b07d5
Update class_ir.py
BobTheBuidler 211ea3c
feat: support_weakrefs=True in mypyc_attr
BobTheBuidler fa595d2
Update vtable.py
BobTheBuidler 292e849
Update prepare.py
BobTheBuidler 259d89a
fix: serialization segfault
BobTheBuidler 2949df3
chore: add comment
BobTheBuidler a116ab1
fix: deserialization discrepancy
BobTheBuidler 7da4e53
feat(test): test mypyc_attr(supports_weakref=True)
BobTheBuidler 34e4862
fix: set Py_TPFLAGS_MANAGED_WEAKREF flag on python>=3.12
BobTheBuidler f43eaae
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] bc96da2
Update emitclass.py
BobTheBuidler 14ad56a
fix: handle weakrefs in tp_dealloc
BobTheBuidler bc82b3e
Update registry.py
BobTheBuidler 7f59edf
Create weakref_ops.py
BobTheBuidler ca22a58
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 408576b
Update weakref_ops.py
BobTheBuidler fd2b234
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from mypyc.ir.rtypes import object_rprimitive | ||
from mypyc.primitives.registry import function_op | ||
|
||
# Weakref operations | ||
|
||
""" | ||
py_new_weak_ref_op = function_op( | ||
name="weakref.weakref", | ||
arg_types=[object_rprimitive], | ||
# TODO: how do I pass NULL as the 2nd arg? | ||
#extra_int_constants=[], | ||
result_type=object_rprimitive, | ||
c_function_name="PyWeakref_NewRef", | ||
) | ||
""" | ||
|
||
py_new_weak_ref_with_callback_op = function_op( | ||
name="weakref.weakref", | ||
arg_types=[object_rprimitive, object_rprimitive], | ||
result_type=object_rprimitive, | ||
c_function_name="PyWeakref_NewRef", | ||
) | ||
|
||
""" | ||
py_new_weak_proxy_op = function_op( | ||
name="weakref.proxy", | ||
arg_types=[object_rprimitive], | ||
result_type=object_rprimitive, | ||
c_function_name="PyWeakref_NewProxy", | ||
) | ||
""" | ||
|
||
py_new_weak_proxy_with_callback_op = function_op( | ||
name="weakref.proxy", | ||
arg_types=[object_rprimitive, object_rprimitive], | ||
result_type=object_rprimitive, | ||
c_function_name="PyWeakref_NewProxy", | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JukkaL I've also added 2 new primitives for weakref.ref and weakref.proxy, when called with 2 args. I'm now working on 2 more primitives when called with 1 arg. I just need to know how to pass a NULL as the 2nd arg to the c func. what would you advise here?