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
Bags to accept non-hashable elements #4
Comments
Maybe, add a list to the backing. Whenever a mutable elem is added/accessed, it would fall back to the list. |
I think this does make sense, it won't reduce performance, it will just make bag more flexible. |
I think if bag isn't hashable then it can't support checking equality of nested objects when they're not ordered the same way. The underlying data type as a list or a tuple means insertion ordering will be preserved and considered when checking equality. I can't seem to find a way to validate that two unordered nested lists are equal but the bags they represent very well might be. This means this will be valid:
But this won't because the different ordering of b([1,3,2,1]) causes the data structure to be different than in the child object in d([1,1,2,3]). Both bags contain the same number of elements and are equal when normally checked together but not here:
|
Bags should accept non-hashable elements. Currently a bag is backed by a
dict, so you can't add a bag to another bag.
The text was updated successfully, but these errors were encountered: