Uh oh!
There was an error while loading. Please reload this page.
gh-134819: Add sys.set_object_tags and sys.get_object_tags - #135073
gh-134819: Add sys.set_object_tags and sys.get_object_tags#135073corona10 wants to merge 13 commits into
Conversation
corona10
commented
Jun 3, 2025
@vstinner@colesbury@Fidget-Spinner@ZeroIntensity |
| { | ||
| assert(object != NULL); | ||
| if (strcmp(tag, "immortal") == 0) { | ||
| _Py_SetImmortal(object); |
There was a problem hiding this comment.
This definitely isn't safe on its own. (Trust me, I've gone down quite the rabbithole in getting arbitrary object immortalization working. It's extraordinarily complex to do safely.)
There was a problem hiding this comment.
Hmm, do you think that we should not allow setting "immortal" tag at this moment?
There was a problem hiding this comment.
Yeah, at least for now. sys.set_object_tags is allowed to ignore tags, right?
There was a problem hiding this comment.
Yeah, we will ignore (and it's intended behavior)
Uh oh!
There was an error while loading. Please reload this page.
vstinner
commented
Jun 3, 2025
As I wrote in the issue, I dislike this API and I prefer the current design: one function per object attribute, such as |
The problem is that the alternative implementation also needs to provide the same functions to pass the unittests and avoid people from checking attributes based on the CPython-only function. So this API will remove unnecessary additional APIs that are only for checking the CPython implementation detail. I also dislike that we are exposing CPython implementation detail to the pure Python function. |
corona10
commented
Jun 3, 2025
So if you think that we're fine with exposing CPython implementation details through Python and C API. I can happily drop this proposal. |
colesbury
commented
Jun 3, 2025
I agree with @vstinner here and still feel the same way as in my comment on the issue. I am also not in a rush to expose these APIs at the Python level. |
ZeroIntensity
commented
Jun 3, 2025
I'm indifferent. I see arguments for both sides that both make sense. In general, I think we do need a way to expose unstable APIs to Python the same way we do in C. It's definitely not fun to have to set up a C extension just so you can get something that is useful at a Python level (e.g., deferred reference counting). I think Donghee makes a good point that prefixing with |
This PR is stale because it has been open for 30 days with no activity. |
vstinner
commented
Apr 27, 2026
I suggest closing this change. |
Uh oh!
There was an error while loading. Please reload this page.