You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't see tests for setting the globals field in HPyModuleDef, and the only reference I could find in the cpython backend is here for error checking.
The NumPy port does use this, but I think that is redundant, since there the objects are globally saved and retrieved but not from the module. Using .global would require being able to fish out the module handles, which is discussed elsewhere.
The text was updated successfully, but these errors were encountered:
You are right. The idea of HPyModuleDef.globals is that one needs to register all HPyGlobal variables such that the interpreter can initialize the C-level value of those and do any internal preparation to be able to use the globals.
For CPython, we don't actually need that because HPyGlobal variables are just C global variables of type PyObject * and those are guaranteed to be initialized to NULL.
But I agree with you: since the contract is that one must register the globals, we should enforce this in the debug mode.
We could do that by writing some marker value to the HPyGlobal.
steve-s
changed the title
Is HPyModuleDef->globals used anywhere?
HPyGlobal: debug mode should check registration in HPyModuleDef->globals
Dec 6, 2023
I though I already had an issue opened for that. I took the liberty and renamed this issue. I think we are using that field in GraalPy (or at least planned to use it) to preallocate our internal array with the actual values for globals.
I don't see tests for setting the
globals
field inHPyModuleDef
, and the only reference I could find in the cpython backend is here for error checking.The NumPy port does use this, but I think that is redundant, since there the objects are globally saved and retrieved but not from the module. Using
.global
would require being able to fish out the module handles, which is discussed elsewhere.The text was updated successfully, but these errors were encountered: