-
Notifications
You must be signed in to change notification settings - Fork 1
Convert ArrayMap
to collections.abc
#4
Description
Selfie has a few generic data structures that we use in lots of places. In order of complexity, they are:
selfie-python-wip/jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/ArrayMap.kt
Line 39 in c41e68c
abstract class ListBackedSet<T>() : AbstractSet<T>() { |
selfie-python-wip/jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/ArrayMap.kt
Lines 248 to 252 in c41e68c
/** | |
* An immutable, sorted, array-backed set - if keys are [String], they have a special sort order | |
* where `/` is the lowest key. | |
*/ | |
class ArraySet<K : Comparable<K>>(private val data: Array<Any>) : ListBackedSet<K>() { |
selfie-python-wip/jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/ArrayMap.kt
Lines 65 to 69 in c41e68c
/** | |
* An immutable, sorted, array-backed map - if keys are [String], they have a special sort order | |
* where `/` is the lowest key. | |
*/ | |
class ArrayMap<K : Comparable<K>, V : Any>(private val data: Array<Any>) : Map<K, V> { |
We should implement them in Python using the collections.abc framework.
ListBackedSet
should extendSet
andSequence
ArrayMap
should extendMapping
We have a few tests for these here, but there should be more.
I think using PEP 695 will make the rest of this easier, but it's not a hard requirement.
Here's an example conversation with ChatGPT for going about this task.