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

PyO3: introduce PyComparedBool type to simplify __richcmp__ methods #21687

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tdyas
Copy link
Contributor

@tdyas tdyas commented Nov 23, 2024

Introduce a PyComparedBool type with three variants (True, False, and NotImplemented) to simplify the boilerplate currently present in most of the __richcmp__ dunder methods.

PyComparedBool is convertible from Option<bool> so a __richcmp__ method can easily return Python True/False when a comparison is supported or NotImplemented just by building an Option<bool> and calling .into().

@tdyas tdyas requested review from benjyw and huonw November 23, 2024 04:13
@tdyas tdyas added category:internal CI, fixes for not-yet-released features, etc. release-notes:not-required PR doesn't require mention in release notes labels Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:internal CI, fixes for not-yet-released features, etc. release-notes:not-required PR doesn't require mention in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant