-
Notifications
You must be signed in to change notification settings - Fork 13
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
LBYL -> EAFP #29
Comments
I personally prefer LBYL but without type checking. That's the reason of typethint. You inform the user of the types to pass and if they don't follow them, that's their fault not ours. |
I also feel like EAFP was more pythonic years ago when typehint wasn't a thing but don't quote me about that. Now with mypy and flake8 era, you have to explicitly handle types unless linters will yell at you. |
Using For other kinds of projects, I may agree with your opinion. |
At the moment of writing, a lot of PyonFX's code use LBYL approach ("look before you leap"). This means that a lot of type checking is done and slow down the whole process.
Instead, we should follow EAFP approach ("it’s easier to ask for forgiveness than permission") and the code should be reviewed using
try ... except
whenever it is possible.Together with making the code follow the common Python coding style, we should also have a little boost in performance and improve readability.
The text was updated successfully, but these errors were encountered: