[mypyc] feat: new primitive for weakref.ref.__call__#19145
[mypyc] feat: new primitive for weakref.ref.__call__#19145BobTheBuidler wants to merge 33 commits intopython:masterfrom
weakref.ref.__call__#19145Conversation
d535f84 to
3b71a7f
Compare
weakref.ref.__call__
f5c4cc8 to
e6e4a6b
Compare
This PR adds a new mypyc primitive for `weakref.ref` I wasn't able to figure out what name mypyc expects for `weakref.proxy`, so I took that out and will keep that for a separate PR later on. ref is more commonly used than proxy anyway. for later, I tried: - weakref.proxy - weakref.ProxyType - weakref.weakproxy no luck with those also for later, I'll need to finish #19145 to add a primitive for `weakref.ref.__call__`
e6e4a6b to
49d9cc0
Compare
| #endif | ||
|
|
||
|
|
||
| PyObject *CPyWeakref_GetRef(PyObject *ref) |
There was a problem hiding this comment.
We need a new C function because of the variability of PyWeakref_GetRef
for more information, see https://pre-commit.ci
d219f8f to
47ab0d4
Compare
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…into weakref-call
for more information, see https://pre-commit.ci
|
Is this still WIP? |
|
Ah no, this one is ready for review. Though I wouldn't call it "complete" quite yet. One open question, I'll add a comment in the code |
| builder: IRBuilder, expr: CallExpr, callee: RefExpr | ||
| ) -> Value | None: | ||
| """Invoke the Specializer callback for a function if one has been registered""" | ||
| if is_weakref_rprimitive(builder.node_type(callee)) and len(expr.args) == 0: |
There was a problem hiding this comment.
I think there's gotta be a better place for this, but I wasn't able to figure out how to make function_op or method_op work with the __call__ method
There was a problem hiding this comment.
@JukkaL There's also one open question here blocking me, and then I can finish this up
edit: hmm. Well it was working, some recent change on master appears to have broken this one. So I guess we have 2 open questions as I don't particularly understand any of the casting code.
for more information, see https://pre-commit.ci
weakref.ref.__call__weakref.ref.__call__
This PR is a follow-up to #19099, adding a new rprimitive type for
weakref.ReferenceTypeand another new custom_op primitive forweakref.ReferenceType.__call__to dereference reference objects.