Skip to content

Conversation

@urbanij
Copy link

@urbanij urbanij commented Aug 7, 2025

This PR enables support for positional pattern matching on the Bit class using Python's match statement (introduced in Python 3.10 via PEP 634).

With this change, it becomes possible to use concise and readable pattern matching with Bit instances. For example:

bit = Bit(0)
match bit:
    case Bit(0):
        print("Matched 0")
    case Bit(1):
        print("Matched 1")   

@cdonovick
Copy link
Collaborator

Sorry for the slow response, I don't think anyone is actively maintaining this project at this point. While this seems like a pretty reasonable pr in isolation I will decline it. The historical motivation for this tool was to modeling operations done in magma. So all operations are expected to be supported in magma which this cannot be. If you are using magma and you need this for your work I might be convinced to change my mind.

@urbanij
Copy link
Author

urbanij commented Sep 18, 2025

Hi, thanks for your answer - I understand. I figured I could open a PR here because I wanted to use some type that could take only 1 or 0 (a bit indeed), without using a boolean, and I remembered this very project from some time ago.

Feel free to close this by all means.
Cheers

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