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

Iterable type checking on first element #35

Open
lemeb opened this issue Oct 3, 2019 · 0 comments
Open

Iterable type checking on first element #35

lemeb opened this issue Oct 3, 2019 · 0 comments

Comments

@lemeb
Copy link

lemeb commented Oct 3, 2019

Per README:

For iterable generics actual type of value is guessed based on the first element.

match([1, 2, 3], List[int], lambda x: x)                        # => [1, 2, 3]
match([1, "b", "a"], List[int], lambda x: x)                    # => [1, "b", "a"]

Is there a specific reason to do this, as opposed to check the type of the value is on every element? It seems like the current implementation is not great if one wants to do strict type checking.

I was considering forking this repo and correcting this [1], but I wanted to double check with you that it was a good idea to do so.

In any case, thank you so much for this kickass package, and have a great day! :)

[1]: I was considering using the TypeGuard library to make things go faster. I'm assuming the reason to guess the value on the first element is performance, but what do I know...

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

No branches or pull requests

1 participant