GeezerVison is showing github.com — Add explicit Python collection conversion adapters by 1ndahous3 · Pull Request #9372 · RustPython/RustPython
Conversation
1ndahous3
commented
Oct 25, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
This proposal comes from my personal project, br3k, which uses an embedded RustPython VM:
The call_between_rust_and_python example also had its own list conversion wrapper.
Summary
- Add
PyListOf<T>, PySetOf<T> and PyDictOf<K, V> for constructing Python collections from Rust iterators. Explicit list conversion includes u8 without changing Vec<u8> conversion to bytes.
- Use Python hashing and equality for sets and dictionaries, propagating construction errors and stopping at the failing item.
- Preserve collection identity when cloning or returning an adapter, with GC traversal of the owned reference.
- Keep element access untyped: type parameters describe construction, while Python can subsequently mutate the collections.
- Replace manual collection conversion in CSV dialect listing, signal sets, and
sys._current_frames() / sys._current_exceptions() while preserving snapshots and object identity.
- Show built-in list conversion alongside a custom domain conversion in the embedding example.
Example
let labels = PyListOf::new(["ready", "done"], vm);
let flags = PySetOf::try_new([1, 2, 1], vm)?;
let counts = PyDictOf::try_new([("ready", 2), ("done", 1)], vm)?;
AI assistance
Written with Codex (GPT-6), reviewed by a human before submission.
Summary by CodeRabbit
- New Features
- Added typed helpers for creating Python lists, dictionaries, and sets from Rust values. Dictionary keys and set items follow Python equality and duplicate-handling behavior.
- Expanded the Rust–Python interoperability example with ordered measurements and list-based values.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-10-25T22:26:25.239861Z |
10d7ff6 |
PR opened |
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Oct 25, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 0dca682 and 10d7ff6.
Files selected for processing: 9
-
crates/stdlib/src/csv.rs
crates/vm/src/convert/dict.rs
crates/vm/src/convert/list.rs
crates/vm/src/convert/mod.rs
crates/vm/src/convert/set.rs
crates/vm/src/stdlib/_signal.rs
crates/vm/src/stdlib/sys.rs
examples/call_between_rust_and_python.py
examples/call_between_rust_and_python.rs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Walkthrough
-
The change adds typed Rust wrappers for Python dictionaries, lists, and sets, exports them from the VM conversion module, and uses them in standard-library functions and a Rust-to-Python example. The wrappers convert iterator inputs and expose the underlying Python containers.
Changes: Typed Container Conversions
| Layer / File(s) |
Summary |
Typed container wrappers crates/vm/src/convert/* |
The conversion module exports PyDictOf, PyListOf, and PySetOf. The wrappers construct Python containers from Rust inputs and provide access, conversion, cloning, and traversal support, with tests for their behavior. |
Standard-library container construction crates/stdlib/src/csv.rs, crates/vm/src/stdlib/_signal.rs, crates/vm/src/stdlib/sys.rs |
list_dialects uses PyListOf; signal functions construct sets with PySetOf; _current_frames and _current_exceptions construct dictionaries with PyDictOf. |
Rust-to-Python example examples/call_between_rust_and_python.rs, examples/call_between_rust_and_python.py |
The example exposes numbers as a Python list and measurements as a list of pairs. The Python callback prints the measurements and flushes the output. |
Priority: Normal
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Feature
Possibly related PRs
Suggested reviewers: youknowone
Merge Risk: Minimal · up to 10d7f
-
No specific issue remains that should block merging after normal checks.
Pre-merge checks: 4 · 1
-
Failed checks: 1 warning
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
 |
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 42 functions across 9 files. |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
Passed checks: 4 passed
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
 |
The title clearly and concisely describes the main change: adding explicit adapters for Python collection conversions. |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
-
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10d7ff6d53
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
this is interesting idea, but let me look in details.
|
1ndahous3 reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
At least 1 approving review is required to merge this pull request.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|