Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

Convert ArrayMap to collections.abc #4

@nedtwigg

Description

@nedtwigg

Selfie has a few generic data structures that we use in lots of places. In order of complexity, they are:

abstract class ListBackedSet<T>() : AbstractSet<T>() {

/**
* 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>() {

/**
* 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 extend Set and Sequence
  • ArrayMap should extend Mapping

We have a few tests for these here, but there should be more.

https://github.com/diffplug/selfie-python-wip/blob/main/jvm/selfie-lib/src/commonTest/kotlin/com/diffplug/selfie/ArrayMapTest.kt

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions