-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
isinstance check against mutable mappings rather than dicts #6792
Comments
yep |
it really is noticeably slower to use |
Using the more general |
I think this is possible. You are welcome to submit a pull-request, with tests for this functionaility |
Are there a lot of mappings that are not dicts? Having to call dict is kind of a minor inconvenience compared to a performance hit for which there is no user facing solution. On the flip side I can see why this is useful since maybe you don't want to be coupled to dicts and you just want to implement the interface. Need performance tests as well. |
I have always thought that I was in fact going to suggest to use singledispatch to improve structure of multi-branch ifs that implement overloading on parameter types and I'm pretty sure it caches the type-to-function-overload lookup somewhere under the hood, so if not borrowing actual code we could borrow some inspiration from it. |
Closing in favor of #58803 |
atm we're checking dict-like by doing isinstance(x, dict), I think we should be using collections.MutableMapping, slightly more general.
The text was updated successfully, but these errors were encountered: