Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling keepalive inference for constructors #242

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

auscompgeek
Copy link
Member

Sometimes we don't actually need keepalives for references passed to constructors. For example, none of Rotation3d's const-ref-taking constructor overloads hold the references in the instance.

Allow an explicit empty list to disable the constructor reference keepalive inference.

Copy link
Member

@virtuald virtuald left a comment

Choose a reason for hiding this comment

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

Seems fine, but please add a test to test_ft_keepalive? And add a doc note.

@auscompgeek
Copy link
Member Author

I actually expected it to work this way already when I read the existing doc.

keepalive: Optional[List[Tuple[int, int]]] = None

Adds py::keep_alive<x,y> to the function. Overrides automatic keepalive support, which retains references passed to constructors.

@virtuald virtuald merged commit d6258c3 into main Dec 30, 2024
32 checks passed
@virtuald virtuald deleted the override-keepalive-infer branch December 30, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants