Skip to content

[Python] Don't rely on heuristic memory policy when passing ownership#21451

Merged
guitargeek merged 1 commit intoroot-project:masterfrom
guitargeek:declare_cpp_owned_arg
Mar 2, 2026
Merged

[Python] Don't rely on heuristic memory policy when passing ownership#21451
guitargeek merged 1 commit intoroot-project:masterfrom
guitargeek:declare_cpp_owned_arg

Conversation

@guitargeek
Copy link
Contributor

If an interface is meant to be used for passing ownership, this should be implemented with an explicit Pythonization instead of relying on heuristics in cppyy, because the heuristics result in many false positives for ownership transfer, manifesting as memory leaks.

We would like to avoid using the heuristic memory policy in the future, and this change is done in preparation for that.

This commit has absolutely no effect on the behavor of the ROOT Python interface at this point, because it's redundant with the heuristic memory policy. But these Pythonization will be important once the strict memory policy is the default.

This is a spinoff from #13593

@github-actions
Copy link

github-actions bot commented Mar 2, 2026

Test Results

    22 files      22 suites   3d 1h 51m 59s ⏱️
 3 808 tests  3 807 ✅ 1 💤 0 ❌
75 726 runs  75 717 ✅ 9 💤 0 ❌

Results for commit 74ec2f4.

Copy link
Member

@vepadulano vepadulano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, makes sense!

If an interface is meant to be used for passing ownership, this should
be implemented with an explicit Pythonization instead of relying on
heuristics in cppyy, because the heuristics result in many false
positives for ownership transfer, manifesting as memory leaks.

We would like to avoid using the heuristic memory policy in the future,
and this change is done in preparation for that.

This commit has absolutely no effect on the behavor of the ROOT Python
interface at this point, because it's redundant with the heuristic
memory policy. But these Pythonization will be important once the strict
memory policy is the default.
@guitargeek guitargeek force-pushed the declare_cpp_owned_arg branch from 74ec2f4 to 6bb019d Compare March 2, 2026 16:41
@guitargeek guitargeek merged commit 7ac08ad into root-project:master Mar 2, 2026
29 checks passed
@guitargeek guitargeek deleted the declare_cpp_owned_arg branch March 2, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants