Skip to content

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.

3 participants