Skip to content

Conversation

@picnixz
Copy link
Member

@picnixzpicnixz commented Oct 2, 2024

This PR moves some functions closer to where they are needed and adds the traversal and clear functions in prepartion to make the window type a heap type.

Note

I always hated dealing with void pointers so I'm grateful if you carefully check that I didn't introduce some decaying calls or weird stuff. In addition, please check that the names were carefully refactored (the functions look all the same and it's very simple to make typos!).

@picnixzpicnixz changed the title Improve curses C API cleanupgh-123961: Improve curses C API cleanupOct 2, 2024
@picnixzpicnixz requested a review from vstinnerOctober 2, 2024 15:21
Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

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

I don't think that traverse() and clear() methods make sense before window_type becomes a heap type.

@picnixz
Copy link
MemberAuthor

I don't think that traverse() and clear() methods make sense before window_type becomes a heap type.

No you're right but I think it would reduce the diff later. At runtime, they will be unused since the type is not a heap type (so they won't even be called). Whenever a new capsule is created, we just have the check that would be effective at runtime.

if (_PyType_HasFeature(_PyType_CAST(window_type), Py_TPFLAGS_HEAPTYPE)){

But if you prefer to have it in the PR which moves it to a heap type, I can do it.

@picnixz
Copy link
MemberAuthor

picnixz commented Oct 2, 2024

Since I don't know when I'll move it to heap types, I'll delay their addition until then.

@picnixzpicnixz requested a review from vstinnerOctober 3, 2024 07:27
@picnixzpicnixz requested a review from vstinnerOctober 3, 2024 10:25
Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@vstinnervstinner enabled auto-merge (squash) October 3, 2024 10:34
@vstinnervstinner merged commit e6dd71d into python:mainOct 3, 2024
@picnixzpicnixz deleted the curses/better-capsule-123961 branch October 3, 2024 10:49
@vstinner
Copy link
Member

Merged, thanks.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@picnixz@vstinner