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
However, these bits have been reused in CPython 3.10, which added a bunch of flags, including:
/* Disallow creating instances of the type: set tp_new to NULL and don't create * the "__new__" key in the type dictionary. */#definePy_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7)
/* Set if the type object is immutable: type attributes cannot be set nor deleted */#definePy_TPFLAGS_IMMUTABLETYPE (1UL << 8)
In the short term, we could probably get by using two of the few remaining free values instead, but that's probably not sustainable in the long term, and I think we should stop assuming we can put anything in type->tp_flags.
The text was updated successfully, but these errors were encountered:
What if we put those flags into the extra allocated memory in HPyType_Extra_t? We can put there also some magic to be able to assert whether type is HPy managed. Edit: ok we need to mark the types not only for asserts. Then we need at least HPy_TPFLAGS_INTERNAL_PURE
As discussed in our dev call on March 3rd, 2022 (see https://github.com/hpyproject/hpy/wiki/dev-call-20220303) we shoudl move most HPy-specific flags to HPyType_Extra_t.
As @steve-s mentioned, we will need a way to identify a pure HPy type. Our idea was to ask CPython to reserve one bit for us. We don't necessarily expect that to be accepted but we would at least expect that they point us to a possible solution.
One idea is that we use a well-known function for, e.g., tp_dealloc. We could still allow custom destructors but always use a well-known one in tp_dealloc and store the custom one in HPyType_Extra_t as well.
We are using these HPy-specific flags:
However, these bits have been reused in CPython 3.10, which added a bunch of flags, including:
In the short term, we could probably get by using two of the few remaining free values instead, but that's probably not sustainable in the long term, and I think we should stop assuming we can put anything in
type->tp_flags
.The text was updated successfully, but these errors were encountered: