◐ Shell
clean mode source ↗

Add basic dict function to c-api by bschoenmaeckers · Pull Request #7929 · RustPython/RustPython

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 7e4eb20b-84d7-498a-9dbe-1db5909414a0

📥 Commits

Reviewing files that changed from the base of the PR and between d407549 and a7c5bdc.

📒 Files selected for processing (2)
  • crates/capi/src/dictobject.rs
  • crates/vm/src/builtins/dict.rs

📝 Walkthrough

Walkthrough

Adds a new capi::dictobject module exposing C-API functions for dict creation, set/get, size, and iteration; exposes the module from capi::lib; and adds a PyDict::next_entry method and widens inner_setitem visibility to support iteration and C-API operations.

Changes

Dictionary C-API Surface

Layer / File(s) Summary
PyDict iteration and visibility change
crates/vm/src/builtins/dict.rs
Adds pub fn next_entry(&self, position: usize) -> Option<(usize, PyObjectRef, PyObjectRef)> and changes inner_setitem visibility from pub(crate) to pub.
Dictionary C-API operations and type checking
crates/capi/src/dictobject.rs
Registers dict type-check helpers and implements exported extern "C" functions: PyDict_New, PyDict_SetItem, PyDict_GetItemRef, PyDict_Size, and PyDict_Next. Includes a disabled pyo3 test module.
Module public export
crates/capi/src/lib.rs
Adds pub mod dictobject; to publicly expose the new C-API module from the crate root.

Sequence Diagram(s)

sequenceDiagram
  participant ComponentA
  participant ComponentB
  ComponentA->>ComponentB: observable interaction
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • youknowone
  • ShaharNaveh

Poem

🐰 I hop in code where dictionaries dwell,
Gates of C open, pointers to tell,
New, set, and get — I nibble each key,
Size and next let me bound merrily,
Hooray, I dance through entries with glee!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add basic dict function to c-api' accurately describes the main change: introducing fundamental dictionary operations to the C-API with PyDict_New, PyDict_SetItem, PyDict_GetItemRef, PyDict_Size, and PyDict_Next.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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 and usage tips.