You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Equality defined between builtin collections respect partitions (#558)
This commit corrects the equality operators between builtin collection types to respect equality partitions. Equality partitions are segments of different collections within which collections can be considered equal and between which collections cannot be considered equal. The three equality partitions are: sequential types (vectors, seqs), maps, and sets.
Several other small changes were made in support of that goal:
* `Map` types now properly support the full Python `Mapping` protocol.
* `Map.__iter__` now acts like a standard Python `Mapping` type, returning an iterable of keys. Formerly, it was an iterable of `MapEntry` types, which was occasionally convenient, but definitely un-idiomatic in Python. This change doesn't really affect Basilisp code though, since Basilisp always calls `.seq()` on maps to iterate over entries.
* Removed the `.iteritems()`, `.iterkeys()`, and `.itervalues()` methods which simply forwarded to the base `pyrsistent.PMap` implementation.
* `Mapping.items()`, `.keys()`, and `.values()` are now supported. All cases relying on the former `__iter__` implementation have generally been updated to use `.items()` (though a few cases were updated to use `.seq()`).
* All builtin `ISeq` types and `IPersistentVector` have been annotated with the marker interface `ISequential` which is attached to all sequential types in that equality partition.
* `IPersistentVector` types are no longer considered `Mapping` types, though they are still considered `IAssociative`. It never really made sense to consider them `Mapping` types and it was generally inconvenient since it is not useful to consider vectors as maps in most cases.
* Removed the custom `Vector.rseq()` implementation since it was undoubtedly no more efficient than Python's `reversed` using the Python `Sequence` protocol.
Two small fixes unrelated to the main changes were also included because I was already in the code:
* `basilisp.core/rest` now never returns `nil`. Instead, it returns the empty seq in any case it would formerly return `nil`.
* I fixed a [deprecation with the PyTest plugin](pytest-dev/pytest#6680) that emitted Warnings every time any Basilisp tests ran.
References:
* [Clojure Collection Model](https://insideclojure.org/2016/03/16/collections/)
* [Sequences](https://insideclojure.org/2015/01/02/sequences/)
0 commit comments