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

add __bool__ for an FSM #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KommuSoft
Copy link
Contributor

Currently when using if my_fsm, it will fallback on __len__ which will raise an OverflowError in case there are an infinite many strings that match the FSM.

We can just check if the FSM is empty. This is "equivalent" with the current implementation in the sense that for FSMs that accept a finite number of strings, the bool will be the same for both versions, but by adding a __bool__ we will also return True if an infinite amount of strings are accepted, and it is less computationally expensive.

@MegaIng
Copy link
Owner

MegaIng commented Mar 6, 2024

Is the library doing if fsm somewhere? Otherwise, use greenery instead. For interegular FSM is really just an internal detail, and I want to move over to just using greenery.fsm.FSM at some point to reduce complexity of this package. Their implementation is also just better.

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