Skip to content

Migrate sortedset - #96

Open
OutSquareCapital wants to merge 71 commits into
devfrom
migrate-sortedset
Open

OutSquareCapital wants to merge 71 commits into
devfrom
migrate-sortedset

Conversation

@OutSquareCapital

@OutSquareCapital OutSquareCapital commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Greptile Summary

The PR migrates sorted collections to shared Rust implementations and subsequently refines comparison, indexing, conversion, representation, and public API behavior.

  • Consolidates sorted-list, set, and dictionary operations around the sorted_rs crate.
  • Refactors Python rich comparisons and macro-generated type casts.
  • Reworks bulk set updates, slice handling, internal storage access, stubs, and tests.
  • Removes public key attributes from keyed set and dictionary variants.

Confidence Score: 4/5

The PR is not yet safe to merge because self-referential sorted-set bulk updates can still deadlock.

The previous blocking finding remains unresolved: update and difference_update acquire the receiver mutex before IntoUpdate::into_set consumes their arguments, while a sorted-set argument is converted into an iterator backed by the same mutex. Consequently, calls such as sorted_set.update(sorted_set) and sorted_set.difference_update(sorted_set) can wait indefinitely on the non-reentrant lock.

Files Needing Attention: src/collections/sorted/traits.rs, crates/sorted_rs/src/set.rs

Important Files Changed

Filename Overview
src/collections/sorted/traits.rs Centralizes sorted collection methods and locking, but the previously reported self-update deadlock remains outstanding.
crates/sorted_rs/src/set.rs Refactors bulk-update conversion and set comparisons; self-referential inputs are still consumed while the receiver lock is held.
crates/sorted_rs/src/inner.rs Reworks internal indexing, slicing, and sequence comparisons without an established new regression.
crates/pyochain_macros/src/try_cast.rs Adds guarded-pattern support and conditional cast generation with no concrete failing current call site.
crates/pyo3_ext/src/pyany.rs Adds a boolean rich-comparison wrapper over the CPython API.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Python[Python sorted collection API] --> Traits[src/collections/sorted traits]
  Traits --> Lock[Shared Arc Mutex state]
  Lock --> SortedRS[crates/sorted_rs algorithms]
  SortedRS --> Storage[Chunked sorted values and indexes]
  SortedRS --> Builtins[Python set or dict backing storage]
Loading

Reviews (2): Last reviewed commit: "refactor: inline more bisect logic in `b..." | Re-trigger Greptile

- directly bind set accessors
- make SetData generic on ListDataMethods
- added `tombi` to dev dependencies
- added it to CI workflow
- reformatted all files with it
- adjusted CONTRIBUTING.md
- considerably simplified the recently added logic related to
  `CompareOp`. no need for complicated traits
- new `rich_compare_bool` method
- refactored/deduplicated a lot of code in list comparisons
- fixed incorrect handling of bisect methods for `SortedKeySet`
- since `__reduce__` is not tested ATM, might as well delete it in the
  meantime, to simplify current work.
- centralize conversions in new dedicated file with macro
- fuse the two list files (key and values) as they became trivial enough
all the traits to their respective, pertinent files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant