Conversation
|
I'm ok with this. While we're at it, we should add wrappers for On Pythons where it isn't available, we can do what the backport in the capicompat header does: https://github.com/python/pythoncapi-compat/blob/f6121eb60f9fe9ff227fc78f9b39d3bd2a81f434/pythoncapi_compat.h#L2224-L2238 |
|
I'd be glad to give it a try. I guess in #5386 right? |
davidhewitt
left a comment
There was a problem hiding this comment.
Thanks for moving this forward. I think my feeling is that we need to test refcounting internally, and we have fairly tightly controlled examples in those cases, so I'd prefer to keep the tests as they currently are until anything should eventually change which motivates changing the tests.
So I think I'd like there to be a pub(crate) replacement which we can migrate internal code to.
As for the proposal of returning an enum, I would prefer not, I think "immortal objects" are an unstable concept for now and IMO a little different from the object's reference count.
16fcbfa to
87621c3
Compare
|
So I created the internal |
Merging this PR will not alter performance
Comparing Footnotes
|
davidhewitt
left a comment
There was a problem hiding this comment.
Thanks, I have some suggestions how we can migrate the tests outside of the main lib.
tests/test_gc.rs
Outdated
There was a problem hiding this comment.
I think we can just remove the println! here, I have a feeling I left those in during debugging at some point 🙈
| #[cfg(not(GraalPy))] | ||
| #[test] | ||
| #[allow(deprecated)] | ||
| fn inherit_dict_drop() { |
There was a problem hiding this comment.
See bound_from_borrowed_ptr_constructors test in instance.rs which uses closure destructor to check for dropping. This test could migrate to use the same strategy to check the dict dropped instead of using the refcount of a sentinel object(). To avoid unsafe probably better to use Arc<AtomicBool> than the mutable bool on the stack which those tests use.
There was a problem hiding this comment.
This is a bit out of my comfort zone but I think at least it should look similar to this
Closes #3357 and PR #4065 which is now obsolete
From Python docs https://docs.python.org/3/glossary.html#term-reference-count
Things yet to be determined in this PR:
get_refcnt? Use#[allow(deprecated)]; Have an internal private method; Remove these assertionsis_noneOther ideas:
Instead of deprecating, return an enum https://docs.python.org/3/c-api/object.html#c.PyUnstable_IsImmortal