-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[BREAKING CHANGE] Writing magic method names as full name #5842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Warning Rate limit exceeded@youknowone has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 51 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (94)
WalkthroughThis change removes the use of the Changes
Sequence Diagram(s)sequenceDiagram
participant RustStruct as Rust Struct (e.g., PyList)
participant PythonVM as Python VM
PythonVM->>RustStruct: Call __getitem__(...)
RustStruct->>RustStruct: Execute __getitem__ logic
RustStruct-->>PythonVM: Return result
Note over RustStruct,PythonVM: All magic methods now use explicit dunder names and attributes.
Possibly related PRs
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (4)
derive/src/lib.rs (1)
72-72: Update documentation example to clarify magic method implementation.The example shows
#[pymethod]for what appears to be a magic method (__add__). Consider updating the documentation to clarify that magic methods now use explicit names with#[pymethod(name = "__add__")]rather than the removedmagicattribute.stdlib/src/sqlite.rs (1)
1325-1338: Renamecls / exc / tbparameters for clarityThe three positional arguments of
__exit__correspond toexc_type,exc_val, andexc_tb. Using more explicit names (or prefixing with_if unused) makes the intent obvious and keeps naming consistent with the many other__exit__implementations in the repo.-fn __exit__( - &self, - cls: PyObjectRef, - exc: PyObjectRef, - tb: PyObjectRef, +fn __exit__( + &self, + exc_type: PyObjectRef, + exc_val: PyObjectRef, + exc_tb: PyObjectRef, vm: &VirtualMachine, ) -> PyResult<()> { - if vm.is_none(&cls) && vm.is_none(&exc) && vm.is_none(&tb) { + if vm.is_none(&exc_type) && vm.is_none(&exc_val) && vm.is_none(&exc_tb) { self.commit(vm) } else { self.rollback(vm) } }Purely a readability / consistency nit – no functional change.
vm/src/builtins/str.rs (2)
516-535: Consider fast-pathing concatenation when either operand is empty
__add__always allocates a freshWtf8Buf, even when one side is''.
This is noticeably frequent in real code (s += '', building strings in a loop, etc.).
A micro-optimisation that matches CPython is to return the non-empty operand directly:@@ - if let Some(other) = other.payload::<PyStr>() { + if let Some(other) = other.payload::<PyStr>() { + if other.is_empty() { + // right operand is '', return left unchanged + return Ok(zelf.to_pyobject(vm)); + } + if zelf.is_empty() { + // left operand is '', return right unchanged + return Ok(other.to_pyobject(vm)); + } let bytes = zelf.as_wtf8().py_add(other.as_wtf8());Cheap, branch-predictable and avoids an allocation in the hottest path.
548-551: Minor: reuse existing helper to avoid tiny boxing cost
__contains__immediately wrapsneedleinPyObjectRefjust to pass it to_contains; the helper already accepts&PyObject.
Dropping the wrapper avoids oneArcinc/dec:- fn __contains__(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult<bool> { - self._contains(&needle, vm) + fn __contains__(&self, needle: &PyObject, vm: &VirtualMachine) -> PyResult<bool> { + self._contains(needle, vm)Call-sites (generated by the macro machinery) will happily pass
&PyObject.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (70)
derive-impl/src/pyclass.rs(9 hunks)derive/src/lib.rs(1 hunks)stdlib/src/array.rs(13 hunks)stdlib/src/contextvars.rs(3 hunks)stdlib/src/mmap.rs(21 hunks)stdlib/src/pystruct.rs(1 hunks)stdlib/src/select.rs(1 hunks)stdlib/src/sqlite.rs(2 hunks)stdlib/src/zlib.rs(1 hunks)vm/src/builtins/asyncgenerator.rs(2 hunks)vm/src/builtins/bool.rs(2 hunks)vm/src/builtins/builtin_func.rs(3 hunks)vm/src/builtins/bytearray.rs(10 hunks)vm/src/builtins/bytes.rs(8 hunks)vm/src/builtins/classmethod.rs(2 hunks)vm/src/builtins/complex.rs(4 hunks)vm/src/builtins/coroutine.rs(1 hunks)vm/src/builtins/descriptor.rs(2 hunks)vm/src/builtins/dict.rs(24 hunks)vm/src/builtins/enumerate.rs(3 hunks)vm/src/builtins/filter.rs(1 hunks)vm/src/builtins/float.rs(8 hunks)vm/src/builtins/function.rs(14 hunks)vm/src/builtins/generator.rs(1 hunks)vm/src/builtins/genericalias.rs(6 hunks)vm/src/builtins/getset.rs(1 hunks)vm/src/builtins/int.rs(9 hunks)vm/src/builtins/iter.rs(2 hunks)vm/src/builtins/list.rs(16 hunks)vm/src/builtins/map.rs(1 hunks)vm/src/builtins/mappingproxy.rs(5 hunks)vm/src/builtins/memory.rs(8 hunks)vm/src/builtins/module.rs(1 hunks)vm/src/builtins/namespace.rs(2 hunks)vm/src/builtins/object.rs(14 hunks)vm/src/builtins/property.rs(4 hunks)vm/src/builtins/range.rs(10 hunks)vm/src/builtins/set.rs(23 hunks)vm/src/builtins/singletons.rs(2 hunks)vm/src/builtins/slice.rs(2 hunks)vm/src/builtins/staticmethod.rs(2 hunks)vm/src/builtins/str.rs(9 hunks)vm/src/builtins/super.rs(1 hunks)vm/src/builtins/tuple.rs(9 hunks)vm/src/builtins/type.rs(20 hunks)vm/src/builtins/union.rs(2 hunks)vm/src/builtins/weakproxy.rs(2 hunks)vm/src/builtins/weakref.rs(1 hunks)vm/src/builtins/zip.rs(2 hunks)vm/src/coroutine.rs(1 hunks)vm/src/exceptions.rs(16 hunks)vm/src/frame.rs(2 hunks)vm/src/import.rs(1 hunks)vm/src/stdlib/ast/python.rs(1 hunks)vm/src/stdlib/collections.rs(15 hunks)vm/src/stdlib/ctypes/base.rs(1 hunks)vm/src/stdlib/ctypes/function.rs(1 hunks)vm/src/stdlib/functools.rs(2 hunks)vm/src/stdlib/io.rs(7 hunks)vm/src/stdlib/itertools.rs(20 hunks)vm/src/stdlib/operator.rs(3 hunks)vm/src/stdlib/os.rs(2 hunks)vm/src/stdlib/sre.rs(4 hunks)vm/src/stdlib/thread.rs(2 hunks)vm/src/stdlib/typing.rs(16 hunks)vm/src/stdlib/winreg.rs(1 hunks)vm/src/suggestion.rs(1 hunks)vm/src/types/slot.rs(5 hunks)vm/src/types/structseq.rs(2 hunks)vm/src/vm/mod.rs(3 hunks)
🧰 Additional context used
🧠 Learnings (59)
derive/src/lib.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
stdlib/src/zlib.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
vm/src/import.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
vm/src/builtins/module.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
vm/src/builtins/map.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/builtins/weakref.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
vm/src/builtins/super.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
vm/src/types/structseq.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/stdlib/ctypes/base.rs (3)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
vm/src/builtins/getset.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
vm/src/builtins/slice.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
vm/src/builtins/iter.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
vm/src/stdlib/thread.rs (4)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Follow Rust best practices for error handling and memory management in all RustPython Rust code.
vm/src/stdlib/functools.rs (3)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/stdlib/ctypes/function.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/stdlib/operator.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
vm/src/builtins/zip.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
vm/src/stdlib/ast/python.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
vm/src/builtins/singletons.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
stdlib/src/select.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
vm/src/stdlib/winreg.rs (3)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Follow Rust best practices for error handling and memory management in all RustPython Rust code.
vm/src/builtins/bool.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/builtins/weakproxy.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/stdlib/io.rs (5)
undefined
<retrieved_learning>
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
</retrieved_learning>
<retrieved_learning>
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
</retrieved_learning>
<retrieved_learning>
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
</retrieved_learning>
<retrieved_learning>
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Follow Rust best practices for error handling and memory management in all RustPython Rust code.
</retrieved_learning>
<retrieved_learning>
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
</retrieved_learning>
vm/src/builtins/enumerate.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
stdlib/src/contextvars.rs (3)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/stdlib/sre.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
vm/src/builtins/asyncgenerator.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/stdlib/os.rs (4)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
derive-impl/src/pyclass.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
vm/src/builtins/union.rs (4)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To find unimplemented methods and contribution opportunities, run './whats_left.py' in the RustPython repository.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Follow Rust best practices for error handling and memory management in all RustPython Rust code.
vm/src/builtins/staticmethod.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
stdlib/src/mmap.rs (3)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/builtins/memory.rs (5)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Follow Rust best practices for error handling and memory management in all RustPython Rust code.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To find unimplemented methods and contribution opportunities, run './whats_left.py' in the RustPython repository.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/builtins/classmethod.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/builtins/genericalias.rs (3)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To find unimplemented methods and contribution opportunities, run './whats_left.py' in the RustPython repository.
vm/src/builtins/range.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/stdlib/collections.rs (3)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
vm/src/builtins/mappingproxy.rs (4)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Follow Rust best practices for error handling and memory management in all RustPython Rust code.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To find unimplemented methods and contribution opportunities, run './whats_left.py' in the RustPython repository.
vm/src/builtins/tuple.rs (6)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Follow Rust best practices for error handling and memory management in all RustPython Rust code.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To find unimplemented methods and contribution opportunities, run './whats_left.py' in the RustPython repository.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
vm/src/exceptions.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/builtins/builtin_func.rs (4)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
vm/src/builtins/bytes.rs (5)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Follow Rust best practices for error handling and memory management in all RustPython Rust code.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
stdlib/src/sqlite.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
vm/src/builtins/str.rs (6)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When comparing behavior with CPython, use the 'python' command explicitly for CPython and 'cargo run --' for RustPython to avoid confusion.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To find unimplemented methods and contribution opportunities, run './whats_left.py' in the RustPython repository.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/builtins/list.rs (3)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/builtins/complex.rs (3)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
vm/src/builtins/function.rs (3)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
vm/src/builtins/object.rs (3)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/types/slot.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
vm/src/builtins/bytearray.rs (6)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Follow Rust best practices for error handling and memory management in all RustPython Rust code.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To find unimplemented methods and contribution opportunities, run './whats_left.py' in the RustPython repository.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When comparing behavior with CPython, use the 'python' command explicitly for CPython and 'cargo run --' for RustPython to avoid confusion.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/builtins/float.rs (4)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Always use 'cargo fmt' to format Rust code and follow the default rustfmt code style when contributing to RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
stdlib/src/array.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/builtins/dict.rs (4)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Follow Rust best practices for error handling and memory management in all RustPython Rust code.
vm/src/stdlib/typing.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
vm/src/builtins/type.rs (7)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Follow Rust best practices for error handling and memory management in all RustPython Rust code.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When comparing behavior with CPython, use the 'python' command explicitly for CPython and 'cargo run --' for RustPython to avoid confusion.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To find unimplemented methods and contribution opportunities, run './whats_left.py' in the RustPython repository.
vm/src/stdlib/itertools.rs (5)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To find unimplemented methods and contribution opportunities, run './whats_left.py' in the RustPython repository.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Follow Rust best practices for error handling and memory management in all RustPython Rust code.
vm/src/builtins/int.rs (4)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To add a Python module to the RustPython interpreter, use 'vm.add_native_module' with the module name and module factory.
vm/src/builtins/set.rs (4)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: When implementing a Python module in Rust for RustPython, use the #[pymodule] attribute and expose functions and classes using #[pyfunction], #[pyclass], and #[pymethod] as appropriate.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Minimize modifications to CPython standard library files in the Lib/ directory; bug fixes should be made through Rust code modifications whenever possible.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: To find unimplemented methods and contribution opportunities, run './whats_left.py' in the RustPython repository.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-26T12:52:11.109Z
Learning: Use the macro system (such as 'pyclass', 'pymodule', 'pyfunction') when implementing Python functionality in Rust for RustPython.
🧬 Code Graph Analysis (14)
vm/src/builtins/module.rs (3)
vm/src/builtins/genericalias.rs (1)
__dir__(171-179)vm/src/builtins/object.rs (1)
__dir__(388-390)vm/src/builtins/type.rs (1)
__dir__(1190-1197)
vm/src/builtins/weakref.rs (11)
vm/src/builtins/dict.rs (1)
__class_getitem__(324-326)vm/src/builtins/list.rs (1)
__class_getitem__(338-340)vm/src/stdlib/collections.rs (1)
__class_getitem__(413-419)vm/src/builtins/mappingproxy.rs (1)
__class_getitem__(174-176)vm/src/builtins/tuple.rs (1)
__class_getitem__(346-348)vm/src/builtins/set.rs (2)
__class_getitem__(788-790)__class_getitem__(1132-1134)vm/src/builtins/asyncgenerator.rs (1)
__class_getitem__(70-72)vm/src/builtins/enumerate.rs (1)
__class_getitem__(58-60)vm/src/stdlib/typing.rs (2)
__class_getitem__(933-939)args(358-364)vm/src/stdlib/itertools.rs (1)
__class_getitem__(66-72)vm/src/stdlib/os.rs (1)
__class_getitem__(590-596)
vm/src/stdlib/ctypes/base.rs (6)
stdlib/src/array.rs (1)
__mul__(1095-1099)vm/src/builtins/bytes.rs (1)
__mul__(463-465)vm/src/builtins/bytearray.rs (1)
__mul__(549-551)vm/src/builtins/list.rs (1)
__mul__(243-245)vm/src/builtins/tuple.rs (1)
__mul__(283-285)vm/src/builtins/str.rs (1)
__mul__(612-614)
vm/src/builtins/coroutine.rs (9)
vm/src/builtins/classmethod.rs (1)
__name__(148-150)vm/src/builtins/function.rs (2)
__name__(436-438)set___name__(441-443)vm/src/builtins/staticmethod.rs (1)
__name__(109-111)vm/src/builtins/type.rs (3)
__name__(560-575)set___name__(762-778)name(416-421)vm/src/builtins/asyncgenerator.rs (2)
__name__(43-45)set___name__(48-50)vm/src/builtins/builtin_func.rs (1)
__name__(83-85)vm/src/builtins/descriptor.rs (1)
__name__(113-115)vm/src/builtins/generator.rs (2)
__name__(41-43)set___name__(46-48)vm/src/builtins/module.rs (2)
name(117-123)name(122-122)
vm/src/builtins/generator.rs (8)
vm/src/builtins/function.rs (2)
__name__(436-438)set___name__(441-443)vm/src/builtins/type.rs (3)
__name__(560-575)set___name__(762-778)name(416-421)vm/src/builtins/asyncgenerator.rs (2)
__name__(43-45)set___name__(48-50)vm/src/builtins/builtin_func.rs (1)
__name__(83-85)vm/src/builtins/coroutine.rs (2)
__name__(38-40)set___name__(43-45)vm/src/builtins/descriptor.rs (1)
__name__(113-115)vm/src/builtins/getset.rs (1)
__name__(134-136)vm/src/builtins/module.rs (2)
name(117-123)name(122-122)
vm/src/builtins/iter.rs (10)
vm/src/builtins/bytes.rs (2)
__length_hint__(694-696)__setstate__(706-710)vm/src/builtins/bytearray.rs (2)
__length_hint__(895-897)__setstate__(906-910)vm/src/builtins/list.rs (6)
__length_hint__(549-551)__length_hint__(594-596)__reduce__(561-565)__reduce__(606-610)__setstate__(554-558)__setstate__(599-603)vm/src/builtins/range.rs (5)
__length_hint__(544-551)__length_hint__(609-612)__setstate__(554-557)__setstate__(615-619)state(670-670)vm/src/builtins/tuple.rs (3)
__length_hint__(468-470)__reduce__(480-484)__setstate__(473-477)vm/src/builtins/str.rs (3)
__length_hint__(287-289)__reduce__(301-306)__setstate__(292-298)vm/src/builtins/enumerate.rs (4)
__length_hint__(110-118)__reduce__(66-71)__reduce__(126-130)__setstate__(121-123)vm/src/builtins/map.rs (2)
__length_hint__(38-44)__reduce__(47-51)vm/src/builtins/filter.rs (1)
__reduce__(38-43)vm/src/builtins/zip.rs (2)
__reduce__(47-60)__setstate__(63-68)
vm/src/stdlib/thread.rs (5)
stdlib/src/mmap.rs (1)
__exit__(922-924)vm/src/builtins/memory.rs (1)
__exit__(650-652)vm/src/stdlib/io.rs (2)
__exit__(435-438)vm(3238-3240)stdlib/src/sqlite.rs (2)
__exit__(1326-1338)__exit__(2099-2101)vm/src/stdlib/os.rs (1)
__exit__(650-652)
vm/src/builtins/singletons.rs (14)
vm/src/builtins/weakproxy.rs (1)
__bool__(92-94)vm/src/builtins/float.rs (1)
__bool__(287-289)vm/src/builtins/int.rs (1)
__bool__(579-581)vm/src/builtins/range.rs (2)
__bool__(270-272)__reduce__(275-282)vm/src/builtins/tuple.rs (1)
__bool__(255-257)vm/src/builtins/complex.rs (1)
__bool__(381-383)vm/src/builtins/bytes.rs (2)
__reduce__(497-504)__reduce__(699-703)vm/src/builtins/bytearray.rs (2)
__reduce__(651-658)__reduce__(899-903)vm/src/builtins/function.rs (1)
__reduce__(740-748)vm/src/builtins/namespace.rs (1)
__reduce__(44-53)vm/src/builtins/list.rs (2)
__reduce__(561-565)__reduce__(606-610)vm/src/builtins/memory.rs (2)
__reduce__(881-883)__reduce__(1128-1132)vm/src/builtins/set.rs (3)
__reduce__(780-785)__reduce__(1124-1129)__reduce__(1311-1327)vm/src/builtins/str.rs (1)
__reduce__(301-306)
stdlib/src/contextvars.rs (13)
vm/src/builtins/bytes.rs (2)
__getitem__(189-191)__len__(150-152)vm/src/builtins/bytearray.rs (2)
__getitem__(245-247)__len__(209-211)vm/src/builtins/list.rs (3)
__getitem__(217-219)__len__(183-185)__class_getitem__(338-340)vm/src/builtins/tuple.rs (3)
__getitem__(298-300)__len__(272-274)__class_getitem__(346-348)vm/src/builtins/str.rs (1)
__getitem__(562-564)vm/src/builtins/set.rs (5)
item(486-486)__len__(546-548)__len__(972-974)__class_getitem__(788-790)__class_getitem__(1132-1134)vm/src/types/slot.rs (3)
__iter__(1311-1313)__iter__(1352-1354)mapping_downcast(1259-1261)vm/src/builtins/asyncgenerator.rs (1)
__class_getitem__(70-72)vm/src/builtins/enumerate.rs (1)
__class_getitem__(58-60)vm/src/builtins/weakref.rs (1)
__class_getitem__(56-58)vm/src/stdlib/typing.rs (1)
__class_getitem__(933-939)vm/src/stdlib/itertools.rs (1)
__class_getitem__(66-72)vm/src/stdlib/os.rs (1)
__class_getitem__(590-596)
stdlib/src/pystruct.rs (7)
vm/src/builtins/bytes.rs (1)
__length_hint__(694-696)vm/src/builtins/bytearray.rs (1)
__length_hint__(895-897)vm/src/builtins/list.rs (2)
__length_hint__(549-551)__length_hint__(594-596)vm/src/stdlib/collections.rs (2)
__length_hint__(632-634)__length_hint__(698-700)vm/src/builtins/tuple.rs (1)
__length_hint__(468-470)vm/src/builtins/set.rs (1)
__length_hint__(1306-1308)vm/src/builtins/str.rs (1)
__length_hint__(287-289)
vm/src/builtins/staticmethod.rs (4)
vm/src/builtins/classmethod.rs (8)
__func__(128-130)__wrapped__(133-135)__module__(138-140)__qualname__(143-145)__name__(148-150)__annotations__(153-155)__isabstractmethod__(158-163)set___isabstractmethod__(166-171)vm/src/builtins/type.rs (5)
__module__(677-691)__qualname__(578-592)__name__(560-575)__annotations__(623-646)value(764-764)vm/src/builtins/descriptor.rs (3)
__qualname__(117-119)__qualname__(252-262)__name__(113-115)vm/src/builtins/property.rs (3)
__isabstractmethod__(241-272)setter(223-229)set___isabstractmethod__(275-280)
vm/src/builtins/classmethod.rs (3)
vm/src/builtins/staticmethod.rs (8)
__func__(89-91)__wrapped__(94-96)__module__(99-101)__qualname__(104-106)__name__(109-111)__annotations__(114-116)__isabstractmethod__(119-124)set___isabstractmethod__(127-132)vm/src/builtins/type.rs (5)
__module__(677-691)__qualname__(578-592)__name__(560-575)__annotations__(623-646)value(764-764)vm/src/builtins/property.rs (3)
__isabstractmethod__(241-272)setter(223-229)set___isabstractmethod__(275-280)
stdlib/src/sqlite.rs (6)
stdlib/src/mmap.rs (2)
__enter__(916-919)__exit__(922-924)vm/src/builtins/memory.rs (2)
__enter__(645-647)__exit__(650-652)stdlib/src/select.rs (2)
__enter__(726-729)__exit__(732-739)vm/src/stdlib/io.rs (2)
__enter__(429-432)__exit__(435-438)vm/src/stdlib/winreg.rs (2)
__enter__(109-111)__exit__(113-115)vm/src/stdlib/os.rs (2)
__enter__(645-647)__exit__(650-652)
vm/src/builtins/bytearray.rs (6)
vm/src/builtins/bytes.rs (12)
__len__(150-152)__sizeof__(165-167)__add__(170-172)__contains__(175-181)__getitem__(189-191)__mul__(463-465)__rmod__(474-476)__reduce_ex__(488-494)__reduce__(497-504)__reduce__(699-703)__length_hint__(694-696)__setstate__(706-710)vm/src/builtins/list.rs (19)
__len__(183-185)__sizeof__(188-191)__add__(146-148)other(133-133)__contains__(258-260)__iadd__(161-169)__getitem__(217-219)__delitem__(316-318)__mul__(243-245)__imul__(248-250)__setitem__(232-239)__reduce__(561-565)__reduce__(606-610)__length_hint__(549-551)__length_hint__(594-596)obj(348-348)obj(350-350)__setstate__(554-558)__setstate__(599-603)vm/src/builtins/tuple.rs (10)
__len__(272-274)__add__(232-252)other(237-237)__contains__(328-330)zelf(243-247)__getitem__(298-300)__mul__(283-285)__reduce__(480-484)__length_hint__(468-470)__setstate__(473-477)vm/src/protocol/buffer.rs (1)
simple(178-186)vm/src/types/slot.rs (3)
mapping_downcast(1259-1261)sequence_downcast(1270-1272)obj(1207-1208)vm/src/builtins/iter.rs (2)
__length_hint__(203-216)state(62-62)
⏰ Context from checks skipped due to timeout of 90000ms (10)
- GitHub Check: Run snippets and cpython tests on wasm-wasi
- GitHub Check: Check Rust code with rustfmt and clippy
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Run snippets and cpython tests (macos-latest)
- GitHub Check: Run rust tests (macos-latest)
- GitHub Check: Run snippets and cpython tests (windows-latest)
- GitHub Check: Run tests under miri
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Run rust tests (windows-latest)
- GitHub Check: Ensure compilation on various targets
🔇 Additional comments (240)
stdlib/src/zlib.rs (1)
407-407: LGTM! Consistent attribute update in commented code.Good practice to update the commented attribute syntax to reflect the new explicit naming convention, maintaining consistency even in unimplemented code.
vm/src/import.rs (1)
214-214: LGTM! Consistent dunder method naming.The change from
traceback()to__traceback__()aligns with the systematic refactoring to use explicit Python dunder method names.vm/src/coroutine.rs (2)
118-118: LGTM! Consistent exception cause setter naming.The change from
set_causetoset___cause__aligns with the systematic refactoring to use explicit dunder method naming for exception handling.
124-124: LGTM! Consistent exception cause setter naming.Same as above - the dunder method naming update maintains functionality while improving consistency.
vm/src/stdlib/ast/python.rs (1)
18-19: LGTM! Proper magic method conversion to explicit dunder naming.The conversion from
#[pymethod(magic)]withfn initto#[pymethod]withfn __init__correctly implements the new explicit naming convention while preserving all functionality.vm/src/suggestion.rs (1)
58-58: LGTM: Consistent with systematic magic method refactoring.The change from
exc.traceback()?toexc.__traceback__()?aligns with the codebase-wide refactoring to use explicit Python dunder method names instead of magic method shortcuts.vm/src/builtins/module.rs (1)
171-172: LGTM: Systematic magic method refactoring applied correctly.The change from
#[pymethod(magic)] fn dirto#[pymethod] fn __dir__follows the codebase-wide pattern of replacing magic method shortcuts with explicit Python dunder method names, while preserving the exact implementation logic.vm/src/builtins/filter.rs (1)
37-38: LGTM: Systematic magic method refactoring applied correctly.The change from
#[pymethod(magic)] fn reduceto#[pymethod] fn __reduce__is consistent with the codebase-wide refactoring to use explicit Python dunder method names, while maintaining the exact serialization protocol implementation.vm/src/frame.rs (2)
386-386: LGTM: Consistent with systematic magic method refactoring.The change from
exception.traceback()toexception.__traceback__()aligns with the codebase-wide refactoring to use explicit Python dunder method names in exception handling.
1711-1711: LGTM: Systematic magic method refactoring applied correctly.The change from
exception.set_cause(cause)toexception.set___cause__(cause)follows the consistent pattern of replacing magic method shortcuts with explicit dunder method names throughout the codebase.vm/src/stdlib/ctypes/base.rs (1)
264-267: LGTM! Correct magic method renaming.The method is correctly renamed from
mulwith themagicattribute to the explicit Python special method name__mul__, consistent with the codebase-wide refactoring effort and Python's canonical naming conventions.vm/src/builtins/weakref.rs (1)
55-58: LGTM! Correct magic method renaming.The method is correctly renamed from
class_getitemwith themagicattribute to the explicit Python special method name__class_getitem__, following the standard pattern used across all builtin types for generic type subscription.stdlib/src/pystruct.rs (1)
194-197: LGTM! Correct magic method renaming.The method is correctly renamed from
length_hintwith themagicattribute to the explicit Python special method name__length_hint__, consistent with the pattern used across iterator types throughout the codebase.vm/src/builtins/generator.rs (1)
40-48: LGTM! Correct magic attribute renaming.The getter and setter for the
__name__attribute are correctly renamed fromname/set_namewith themagicattribute to the explicit Python special attribute names__name__/set___name__, consistent with the pattern used across coroutines, async generators, and functions.vm/src/builtins/coroutine.rs (1)
37-45: LGTM! Correct magic attribute renaming.The getter and setter for the
__name__attribute are correctly renamed fromname/set_namewith themagicattribute to the explicit Python special attribute names__name__/set___name__, consistent with the pattern used across generators, async generators, and functions.vm/src/builtins/map.rs (2)
37-38: Correctly renamed magic method to use explicit dunder naming.The method
length_hinthas been appropriately renamed to__length_hint__and themagicattribute removed, aligning with Python's special method naming conventions.
46-47: Correctly renamed magic method to use explicit dunder naming.The method
reducehas been appropriately renamed to__reduce__and themagicattribute removed, following Python's pickling protocol conventions.vm/src/builtins/namespace.rs (2)
43-44: Correctly renamed magic method to use explicit dunder naming.The method
reducehas been appropriately renamed to__reduce__and themagicattribute removed, consistent with Python's pickling protocol.
99-99: Good consistency in using the new dunder method naming internally.The internal call has been updated from
dict.len()todict.__len__(), maintaining consistency with the new explicit dunder method naming convention throughout the codebase.vm/src/stdlib/ctypes/function.rs (2)
202-203: Correctly renamed property getter to use explicit dunder naming.The getter method
namehas been appropriately renamed to__name__and themagicattribute removed, aligning with Python's standard__name__attribute for callable objects.
207-208: Correctly renamed property setter to use explicit dunder naming.The setter method
set_namehas been appropriately renamed toset___name__and themagicattribute removed, maintaining consistency with the getter method naming.vm/src/stdlib/thread.rs (2)
161-162: Correctly renamed context manager method to use explicit dunder naming.The method
exithas been appropriately renamed to__exit__and themagicattribute removed, aligning with Python's context manager protocol.
247-248: Correctly renamed context manager method to use explicit dunder naming.The method
exitin RLock has been appropriately renamed to__exit__and themagicattribute removed, maintaining consistency with Python's context manager protocol.vm/src/builtins/super.rs (2)
138-139: Correctly renamed property getter to use explicit dunder naming.The getter method
thisclasshas been appropriately renamed to__thisclass__and themagicattribute removed, aligning with Python's special attributes for super objects.
143-144: Correctly renamed property getter to use explicit dunder naming.The getter method
self_classhas been appropriately renamed to__self_class__and themagicattribute removed, maintaining consistency with Python's special attributes for super objects.vm/src/builtins/getset.rs (3)
133-136: LGTM: Correct standardization to dunder namingThe renaming from
nameto__name__and removal of themagicflag correctly aligns with Python's data model for descriptor objects.
138-141: LGTM: Proper qualname attribute namingThe change from
qualnameto__qualname__correctly follows Python's naming convention for qualified names in descriptors.
143-146: LGTM: Correct objclass attribute standardizationThe renaming from
objclassto__objclass__properly implements the standard Python descriptor protocol.vm/src/builtins/zip.rs (2)
46-60: LGTM: Correct pickle protocol method namingThe renaming from
reduceto__reduce__and removal of themagicflag correctly follows Python's pickle protocol conventions.
62-68: LGTM: Proper setstate method standardizationThe change from
setstateto__setstate__correctly implements the standard Python pickle protocol method.vm/src/builtins/slice.rs (2)
185-196: LGTM: Correct pickle protocol implementation for PySliceThe renaming from
reduceto__reduce__and removal of themagicflag correctly follows Python's pickle protocol for slice objects.
320-323: LGTM: Proper ellipsis pickle supportThe change from
reduceto__reduce__correctly implements the standard Python pickle protocol for ellipsis objects.vm/src/types/structseq.rs (2)
50-75: LGTM: Correct trait method standardizationThe renaming from
reprto__repr__and removal of themagicflag correctly aligns the trait with Python's data model for string representation.
77-80: LGTM: Proper pickle protocol in traitThe change from
reduceto__reduce__correctly implements the standard Python pickle protocol in the trait interface.vm/src/vm/mod.rs (3)
462-462: LGTM: Correct exception traceback accessThe change from
e.traceback()toe.__traceback__()correctly uses the standardized dunder method name.
832-839: LGTM: Consistent exception context handlingThe method calls to
__context__()andset___context__()are consistent with the standardized naming convention for exception context handling.
260-260: Verify triple underscore setter naming conventionThe call to
set___cause__uses three underscores, which seems unusual. Please verify this is the correct naming convention for exception cause setters.#!/bin/bash # Search for other triple underscore setter method definitions to verify naming convention rg -A 2 "set___" --type ruststdlib/src/select.rs (2)
725-729: LGTM! Context manager protocol correctly implemented.The method correctly implements the
__enter__protocol by returning self, which is standard behavior for context managers.
731-739: LGTM! Context manager exit protocol correctly implemented.The
__exit__method properly callsclose()to clean up resources, which is the expected behavior for the context manager protocol.vm/src/builtins/iter.rs (3)
202-216: LGTM! Iterator length hint protocol correctly implemented.The method properly implements the
__length_hint__protocol by returning the estimated number of remaining items in the sequence iterator.
218-221: LGTM! Pickling protocol correctly implemented.The
__reduce__method properly enables pickling support for sequence iterators by delegating to the internal reduce implementation.
223-226: LGTM! Unpickling protocol correctly implemented.The
__setstate__method properly enables unpickling support by restoring the iterator's internal state.vm/src/builtins/singletons.rs (3)
47-50: LGTM! Boolean conversion protocol correctly implemented.The method correctly implements
__bool__forPyNone, always returningfalseas expected for Python'sNonesingleton.
98-101: LGTM! Boolean conversion protocol correctly implemented.The method correctly implements
__bool__forPyNotImplemented, always returningtrueas expected for Python'sNotImplementedsingleton.
103-106: LGTM! Pickling protocol correctly implemented.The
__reduce__method correctly returns the string name forNotImplemented, enabling proper pickling support for this singleton.vm/src/stdlib/winreg.rs (3)
104-107: LGTM! Boolean conversion protocol correctly implemented.The method correctly implements
__bool__by checking if the registry key handle is not null, which is the appropriate way to determine if a registry key is valid.
108-111: LGTM! Context manager entry protocol correctly implemented.The
__enter__method correctly returns self, following the standard context manager pattern for registry keys.
112-115: LGTM! Context manager exit protocol correctly implemented.The
__exit__method properly callsClose()to ensure the registry key is properly closed when exiting the context, providing proper resource management.vm/src/stdlib/operator.rs (3)
359-365: LGTM! Pickling protocol correctly implemented for attrgetter.The
__reduce__method properly returns a tuple containing the class and attribute names, enabling correct reconstruction during unpickling.
458-462: LGTM! Pickling protocol correctly implemented for itemgetter.The
__reduce__method properly returns a tuple containing the class and items, enabling correct reconstruction during unpickling.
529-547: LGTM! Pickling protocol correctly implemented for methodcaller.The
__reduce__method handles both simple cases (no kwargs) and complex cases (with kwargs using partial functions), ensuring proper reconstruction during unpickling.vm/src/stdlib/functools.rs (2)
103-104: LGTM! Proper migration to explicit dunder method naming.The change from
#[pymethod(magic)]withsetstateto#[pymethod]with__setstate__correctly aligns with Python's special method naming conventions. The method implementation remains unchanged and properly handles the pickle protocol state restoration.
293-293: LGTM! Consistent use of explicit dunder method call.The change from
.module(vm)to.__module__(vm)is consistent with the broader refactoring to use explicit dunder method names throughout the codebase. This maintains the same functionality while following Python's special attribute naming conventions.stdlib/src/sqlite.rs (2)
1320-1324:__enter__looks goodThe context-manager entry simply returns the
Connectionitself, which matches CPython’s sqlite3 behaviour.
No further action needed.
2093-2101: Blob context-manager implementation is fine
__enter__returnsself, and__exit__closes the blob without attempting to suppress exceptions – identical to CPython’s behaviour.
No issues spotted.vm/src/builtins/property.rs (3)
152-165: LGTM! Correct mapping to Python special method name.The renaming of
set_nametoset___name__properly reflects the Python__set_name__descriptor protocol method, and removing themagicattribute makes the special method nature explicit.
240-272: LGTM! Proper abstract method attribute naming.The changes correctly rename:
isabstractmethod→__isabstractmethod__set_isabstractmethod→set___isabstractmethod__These align with Python's
__isabstractmethod__attribute convention for abstract methods.
292-292: LGTM! Consistent internal call update.The update from
qualname(vm)to__qualname__(vm)is consistent with the broader refactoring to use explicit dunder method names.stdlib/src/contextvars.rs (3)
200-221: LGTM! Correct mapping to Python special methods.The systematic renaming follows Python conventions correctly:
getitem→__getitem__(subscription protocol)len→__len__(length protocol)iter→__iter__(iteration protocol)The multi-line parameter formatting also improves readability.
263-265: LGTM! Consistent internal call update.The AsMapping implementation correctly updates the internal call to use
__len__()instead of the oldlen()method name, maintaining consistency with the method renaming.
479-486: LGTM! Proper class method naming.The renaming of
class_getitemto__class_getitem__correctly reflects Python's generic type subscripting protocol and removes themagicattribute appropriately.vm/src/stdlib/os.rs (2)
584-596: LGTM! Correct path protocol and generic type methods.The changes properly map to Python special methods:
fspath→__fspath__(PEP 519 path protocol)class_getitem→__class_getitem__(generic type subscripting)Both follow Python conventions and maintain the original functionality.
644-652: LGTM! Proper context manager protocol methods.The renaming correctly implements the context manager protocol:
enter→__enter__exit→__exit__These are the standard Python dunder methods for context managers and the logic is preserved.
vm/src/builtins/bool.rs (3)
113-119: LGTM! Correct format method naming.The renaming of
formatto__format__properly reflects Python's string formatting protocol and removes themagicattribute appropriately.
122-167: LGTM! Proper bitwise operation methods.The systematic renaming correctly maps to Python special methods:
or→__or__(bitwise OR)and→__and__(bitwise AND)xor→__xor__(bitwise XOR)The internal calls on lines 131, 147, and 163 are consistently updated to use the new dunder method names.
173-179: LGTM! Consistent trait implementation update.The AsNumber trait implementation correctly references the renamed dunder methods, maintaining consistency with the method name changes throughout the file.
vm/src/builtins/weakproxy.rs (2)
82-109: LGTM! Correct mapping to Python special methods.The systematic renaming properly reflects Python protocols:
str→__str__(string representation)bool→__bool__(truthiness testing)bytes→__bytes__(bytes conversion)reversed→__reversed__(reverse iteration)contains→__contains__(membership testing)All changes maintain the original functionality while making the special method nature explicit.
192-193: LGTM! Consistent internal call update.The AsSequence trait implementation correctly updates the internal call to use
__contains__(), maintaining consistency with the method renaming.vm/src/builtins/enumerate.rs (5)
57-61: LGTM!The change correctly updates the class method to use the explicit dunder name
__class_getitem__and removes themagicattribute.
65-71: LGTM!The change correctly updates the method to use the explicit dunder name
__reduce__and removes themagicattribute.
109-118: LGTM!The change correctly updates the method to use the explicit dunder name
__length_hint__and removes themagicattribute.
120-123: LGTM!The change correctly updates the method to use the explicit dunder name
__setstate__and removes themagicattribute.
125-130: LGTM!The change correctly updates the method to use the explicit dunder name
__reduce__and removes themagicattribute.vm/src/stdlib/sre.rs (4)
499-506: LGTM!The change correctly updates the class method to use the explicit dunder name
__class_getitem__and removes themagicattribute.
724-736: LGTM!The change correctly updates the method to use the explicit dunder name
__getitem__and removes themagicattribute.
813-820: LGTM!The change correctly updates the class method to use the explicit dunder name
__class_getitem__and removes themagicattribute.
827-831: LGTM!The internal method call correctly updated to use the new dunder method name
__getitem__.vm/src/builtins/asyncgenerator.rs (5)
42-45: LGTM!The change correctly updates the getter to use the explicit dunder name
__name__and removes themagicattribute.
47-50: LGTM!The setter correctly uses the
set___name__naming convention and removes themagicattribute. The non-standard naming is handled by the automatic#[allow(non_snake_case)]addition in the derive macro.
69-72: LGTM!The change correctly updates the class method to use the explicit dunder name
__class_getitem__and removes themagicattribute.
77-80: LGTM!The change correctly updates the method to use the explicit dunder name
__aiter__and removes themagicattribute.
82-85: LGTM!The change correctly updates the method to use the explicit dunder name
__anext__and removes themagicattribute.vm/src/builtins/union.rs (6)
87-90: LGTM!The change correctly updates the getter to use the explicit dunder name
__parameters__and removes themagicattribute.
92-95: LGTM!The change correctly updates the getter to use the explicit dunder name
__args__and removes themagicattribute.
97-112: LGTM!The change correctly updates the method to use the explicit dunder name
__instancecheck__, removes themagicattribute, and properly updates the internal call to__args__().
114-129: LGTM!The change correctly updates the method to use the explicit dunder name
__subclasscheck__, removes themagicattribute, and properly updates the internal call to__args__().
131-135: LGTM!The change correctly updates the method to use the explicit dunder name
__or__while maintaining the__ror__alias, and removes themagicattribute.
236-243: LGTM!The AsNumber trait implementation correctly updated to call the renamed
__or__method.derive-impl/src/pyclass.rs (5)
1231-1231: LGTM!Correctly removes "magic" from the allowed method attributes.
755-760: LGTM!The automatic addition of
#[allow(non_snake_case)]for setter methods with dunder names properly handles the naming convention.
791-796: LGTM!Consistently applies the non_snake_case allowance for getset setters.
951-956: LGTM!Consistently applies the non_snake_case allowance for member setters.
1386-1398: LGTM!The slot name normalization correctly strips the double underscores to match the expected slot naming convention.
vm/src/stdlib/io.rs (8)
428-432: LGTM! Correct standardization of context manager entry method.The change from
#[pymethod(magic)]with method nameenterto#[pymethod]with__enter__properly follows Python's special method naming conventions for context managers.
434-438: LGTM! Correct standardization of context manager exit method.The change from
#[pymethod(magic)]with method nameexitto#[pymethod]with__exit__properly follows Python's special method naming conventions for context managers.
1413-1413: LGTM! Consistent with dunder method naming standardization.The change from
e.str(vm)toe.__str__(vm)aligns with the broader refactoring to use explicit Python dunder method names throughout the codebase.
1562-1565: LGTM! Correct standardization of string representation method.The change from
#[pymethod(magic)]with method namereprto#[pymethod]with__repr__properly follows Python's special method naming conventions for object representation.
1604-1607: LGTM! Correct standardization of serialization method.The change from
#[pymethod(magic)]with method namereduceto#[pymethod]with__reduce__properly follows Python's special method naming conventions for object serialization.
1683-1683: LGTM! Consistent with dunder method naming standardization.The change from
e.set_context(Some(e1))toe.set___context__(Some(e1))aligns with the broader refactoring to use explicit Python dunder method names for exception handling.
2997-3000: LGTM! Consistent serialization method standardization.The change from
#[pymethod(magic)]with method namereduceto#[pymethod]with__reduce__maintains consistency with Python's special method naming conventions across all IO classes.
4506-4509: LGTM! Complete standardization across all IO classes.The change from
#[pymethod(magic)]with method namereduceto#[pymethod]with__reduce__completes the consistent application of Python's special method naming conventions across all IO implementations.vm/src/builtins/descriptor.rs (2)
112-143: LGTM! Excellent systematic refactoring to canonical Python dunder names.The renaming from
name,qualname,doc,text_signature,objclass,reduceto their canonical Python dunder equivalents (__name__,__qualname__,__doc__,__text_signature__,__objclass__,__reduce__) is correct and improves consistency. The removal of themagicattribute from the decorators aligns with the broader codebase refactoring.
246-262: LGTM! Consistent application of dunder naming pattern.The
PyMemberDescriptorchanges follow the same pattern asPyMethodDescriptor, correctly renamingdocandqualnameto__doc__and__qualname__respectively. The logic remains unchanged.vm/src/builtins/mappingproxy.rs (2)
119-205: LGTM! Proper implementation of Python dunder method naming.The systematic renaming from
getitem,contains,len, etc. to their canonical Python dunder equivalents (__getitem__,__contains__,__len__, etc.) is correct. The removal of themagicattribute and use of plain#[pymethod]aligns with the codebase refactoring.
225-270: LGTM! Protocol implementations correctly updated.The
AsMappingandAsNumbertrait implementations have been properly updated to call the renamed dunder methods (__len__,__getitem__,__or__,__ior__). This ensures consistency between the public Python interface and internal protocol usage.vm/src/builtins/staticmethod.rs (2)
88-132: LGTM! Consistent property renaming to Python dunder conventions.The systematic renaming of property getters from
func,wrapped,module,qualname,name,annotations,isabstractmethodto their canonical Python dunder equivalents is correct and follows the established pattern. The logic for each property remains unchanged.
150-157: LGTM! Representable implementation correctly updated.The calls to
class.__qualname__(vm)andclass.__module__(vm)correctly use the renamed dunder methods, ensuring consistency with the property renamings above.vm/src/builtins/classmethod.rs (2)
127-171: LGTM! Consistent property renaming following Python conventions.The systematic renaming of property getters mirrors the pattern established in
staticmethod.rsand correctly implements canonical Python dunder names. The underlying logic for accessing the callable's attributes remains unchanged.
182-188: LGTM! Representable trait correctly updated.The
Representableimplementation has been properly updated to call__qualname__and__module__instead of the old non-dunder names, maintaining consistency with the property renamings.stdlib/src/mmap.rs (3)
419-454: LGTM! Protocol implementations correctly updated.The
AsBuffer,AsMapping, andAsSequencetrait implementations have been properly updated to call the renamed dunder methods (__len__,getitem_inner,setitem_inner). The buffer descriptor correctly uses__len__()for size calculation.
499-924: LGTM! Comprehensive method renaming to Python dunder conventions.The systematic renaming of methods from
len,getitem,setitem,enter,exitto their canonical Python dunder equivalents (__len__,__getitem__,__setitem__,__enter__,__exit__) is correct. The context manager methods (__enter__/__exit__) properly follow Python's context manager protocol. All method implementations remain unchanged, only the names have been updated.
576-1084: LGTM! Internal calls consistently updated.All internal method calls have been properly updated to use
__len__()instead oflen(), ensuring consistency throughout the implementation. The helper methods have been appropriately renamed from_getitem/_setitemtogetitem_inner/setitem_inner, which follows better naming conventions for internal helpers.vm/src/builtins/memory.rs (4)
644-695: LGTM! Excellent standardization of magic method names.The systematic renaming of magic methods to their canonical Python dunder forms (
__enter__,__exit__,__getitem__,__delitem__,__len__) improves code clarity by making the Python special method protocol explicit rather than relying on themagicattribute annotation.
842-883: LGTM! Consistent dunder method naming in PyMemoryView.The renaming of
setitemto__setitem__,reduce_exto__reduce_ex__, andreduceto__reduce__maintains the same functionality while following Python's canonical special method naming conventions.
966-990: LGTM! Updated internal calls to use new dunder method names.The trait implementations correctly update their internal calls to use the renamed dunder methods (
__len__(),__getitem__(),__setitem__()), ensuring consistency throughout the codebase.
1127-1148: LGTM! Iterator implementation updated consistently.The PyMemoryViewIterator methods are properly renamed to
__reduce__and internal calls updated to use__len__(), maintaining consistency with the broader refactoring effort.vm/src/builtins/genericalias.rs (4)
139-152: LGTM! Property names standardized to Python conventions.The renaming of properties to their canonical dunder forms (
__parameters__,__args__,__origin__) makes the code more consistent with Python's special attribute naming conventions.
154-212: LGTM! Magic methods properly renamed to dunder equivalents.All magic methods are correctly renamed to their canonical Python forms (
__getitem__,__dir__,__reduce__,__mro_entries__,__instancecheck__,__subclasscheck__,__ror__,__or__) while maintaining the same functionality.
324-343: LGTM! Trait implementations updated with new method names.The AsMapping and AsNumber trait implementations correctly use the renamed dunder methods (
__getitem__(),__or__()) in their function calls, ensuring consistency throughout the implementation.
362-402: LGTM! Comparison and attribute access traits updated consistently.The Comparable and GetAttr trait implementations properly call the renamed dunder methods (
__origin__(),__args__()) while maintaining the same comparison and attribute access logic.vm/src/stdlib/collections.rs (4)
96-98: LGTM! Copy method properly dual-named.The
copymethod correctly includes both the regular name and the__copy__magic method name, following Python's copy protocol conventions.
253-420: LGTM! Comprehensive magic method standardization in PyDeque.All magic methods are systematically renamed to their canonical dunder forms (
__reversed__,__getitem__,__setitem__,__delitem__,__contains__,__mul__,__imul__,__len__,__bool__,__add__,__iadd__,__reduce__). The__class_getitem__method is correctly annotated as#[pyclassmethod]for class-level generic typing support.
499-537: LGTM! Sequence trait implementation updated consistently.The AsSequence trait implementation correctly calls the renamed dunder methods (
__len__(),__mul__(),__getitem__(),__setitem__(),__delitem__(),__imul__()) in all its function mappings, maintaining consistency with the method renames.
631-717: LGTM! Iterator classes updated with dunder method naming.Both PyDequeIterator and PyReverseDequeIterator are properly updated with dunder method names (
__length_hint__,__reduce__) and their internal calls use the renamed methods (__len__(),__reversed__()), maintaining consistency throughout the iterator implementations.vm/src/builtins/builtin_func.rs (2)
78-130: LGTM! Builtin function attributes standardized to dunder forms.All special attributes and methods in PyNativeFunction are correctly renamed to their canonical Python forms (
__module__,__name__,__qualname__,__doc__,__reduce__,__reduce_ex__,__text_signature__) while removing themagicattribute from annotations. This improves code clarity and follows Python conventions.
154-176: LGTM! PyNativeMethod updated consistently with dunder naming.The PyNativeMethod class properly adopts the dunder naming convention for
__qualname__and__reduce__, maintaining consistency with the broader refactoring effort across builtin types.vm/src/builtins/str.rs (7)
286-307: Magic-method renaming looks correct & keeps iterator semantics intact
__length_hint__,__setstate__, and__reduce__are now exposed with their canonical dunder names and their bodies are unchanged, so behaviour as observed by user-code is preserved.
No issues spotted.
605-608:__sizeof__omission is acceptable but document the deviationCPython reports
sys.getsizeof('') == 49(64-bit) because it includes allocator
overhead and the implicit trailing nul.
Here we only returnsize_of::<Self>() + len, which will under-report.
That’s fine for RustPython, but worth a doc-comment so users don’t assume parity.
611-614: Alias strategy for__mul__/__rmul__is neatExposing the same body twice with
#[pymethod(name = "__rmul__")]keeps code DRY
and fully matches CPython semantics.
Nicely done.
923-926: Correct CPython behaviour: returnNotImplementedfrom__rmod__CPython also returns
NotImplementedfor the RHS%on strings; implementation matches.
1434-1437:__getnewargs__keeps pickling compatibilityReturning a 1-tuple of the underlying UTF-8 data is exactly what the pickle
protocol expects forstr.
1456-1461:__str__preserves subclass identity when possibleUsing
into_exact_orensures subclasses don’t get collapsed to basestr
unnecessarily. Good call.
1553-1555: Direct call toPyStr::__add__matches CPython C-API semantics
PySequenceMethods::concatin CPython bypasses overridden__add__; your direct
Rust call does the same so behaviour is faithful.vm/src/exceptions.rs (4)
97-97: LGTM: Exception accessor calls updated to use dunder methods.The internal calls to exception properties have been correctly updated to use the new dunder method names (
__cause__,__context__,__traceback__), maintaining consistency with the refactored method definitions.Also applies to: 104-104, 135-135, 313-313
581-627: LGTM: Exception property methods properly renamed to dunder equivalents.The exception property getters and setters have been correctly refactored:
- Removed
magicattributes from#[pygetset]annotations- Renamed methods to explicit dunder forms (
__traceback__,__cause__,__context__)- Renamed setters with triple underscores (
set___traceback__,set___cause__,set___context__)This standardizes the naming convention and aligns with Python's canonical method naming.
639-683: LGTM: Base exception magic methods correctly refactored.The magic methods have been properly updated:
- Removed
magicattribute from#[pymethod]annotations- Renamed methods to explicit dunder forms (
__str__,__reduce__,__setstate__)- Functionality and logic remain unchanged
This aligns with the PR objective of standardizing Python special method naming.
1361-1374: LGTM: Exception type magic methods systematically refactored.All exception type magic methods have been consistently updated across the types module:
- Removed
magicattributes from method annotations- Renamed methods to explicit dunder forms (
__reduce__,__str__)- Internal calls to base exception methods updated to use dunder names (e.g.,
exc.__str__(vm))The refactoring maintains consistency across all exception types and preserves the original functionality.
Also applies to: 1395-1406, 1482-1548, 1680-1725, 1798-1822, 1848-1873, 1898-1919
vm/src/builtins/tuple.rs (3)
231-348: LGTM: Tuple magic methods systematically refactored to dunder names.All tuple magic methods have been correctly updated:
- Removed
magicattributes from#[pymethod]and#[pyclassmethod]annotations- Renamed methods to explicit dunder forms (
__add__,__bool__,__len__,__mul__,__getitem__,__contains__,__getnewargs__,__class_getitem__)- Functionality and method signatures remain unchanged
This standardizes the naming convention and improves code clarity by making Python special methods explicit.
367-370: LGTM: AsSequence trait updated to call renamed methods.The trait implementation has been correctly updated to call the renamed dunder methods (
__len__,__add__), maintaining consistency with the refactored method names.
467-484: LGTM: Tuple iterator magic methods consistently refactored.The PyTupleIterator magic methods have been properly updated:
- Removed
magicattributes from#[pymethod]annotations- Renamed methods to explicit dunder forms (
__length_hint__,__setstate__,__reduce__)This maintains consistency with the broader refactoring effort across the tuple module.
vm/src/builtins/range.rs (8)
228-262: LGTM: Explicit dunder method namingThe transition from
#[pymethod(magic)]with shorthand namereversedto#[pymethod]with explicit__reversed__name improves code clarity and follows Python's special method conventions. The internal call to__len__()is also correctly updated.
264-267: LGTM: Standard magic method renameCorrectly renames the length method to its explicit Python dunder name
__len__.
269-272: LGTM: Boolean magic method renameCorrectly renames the boolean conversion method to its explicit Python dunder name
__bool__.
274-310: LGTM: Pickling and item access methodsBoth
__reduce__and__getitem__method renames are correct and follow Python's special method conventions for object serialization and item access respectively.
340-343: LGTM: Container membership methodCorrectly renames the containment check method to its explicit Python dunder name
__contains__.
380-380: LGTM: Updated internal method callsInternal method calls are correctly updated to use the new dunder method names (
__len__()and__getitem__()), maintaining consistency with the renamed methods.Also applies to: 393-393, 477-477
543-568: LGTM: Iterator magic methods for PyLongRangeIteratorAll magic method renames (
__length_hint__,__setstate__,__reduce__) are correctly implemented with explicit dunder names and proper attribute changes.
608-630: LGTM: Iterator magic methods for PyRangeIteratorConsistent magic method renames for the range iterator class, maintaining the same pattern as the long range iterator.
vm/src/types/slot.rs (4)
899-907: LGTM: Descriptor protocol methodCorrectly renames the descriptor get method to its explicit Python dunder name
__get__, improving consistency with Python's descriptor protocol.
1025-1077: LGTM: Rich comparison protocol methodsAll comparison methods are correctly renamed to their explicit Python dunder equivalents (
__eq__,__ne__,__lt__,__le__,__ge__,__gt__). This improves consistency with Python's rich comparison protocol.
1191-1194: LGTM: Attribute access methodCorrectly renames the attribute getter method to its explicit Python dunder name
__getattribute__.
1221-1235: LGTM: Attribute modification methodsBoth
__setattr__and__delattr__method renames are correct and follow Python's attribute access protocol for setting and deleting attributes.vm/src/builtins/bytes.rs (5)
149-152: LGTM: Core sequence protocol methodsAll fundamental sequence magic methods (
__len__,__sizeof__,__contains__,__getitem__) are correctly renamed to their explicit Python dunder equivalents, improving consistency with Python's sequence protocol.Also applies to: 164-167, 174-181, 188-191
169-172: LGTM: Arithmetic and special methodsArithmetic operations (
__add__,__mul__,__rmod__) and pickling support (__getnewargs__) methods are correctly renamed to their explicit Python dunder names.Also applies to: 462-465, 473-476, 478-482
487-504: LGTM: Pickling and conversion methodsPickling methods (
__reduce_ex__,__reduce__) and type conversion (__bytes__) are correctly renamed. The internal call update on line 493 to use__reduce__()maintains consistency.Also applies to: 509-516
607-607: LGTM: Updated protocol implementationInternal call correctly updated to use the renamed
__contains__()method, maintaining consistency with the method renames.
693-710: LGTM: Iterator magic methodsIterator magic methods (
__length_hint__,__reduce__,__setstate__) are correctly renamed to their explicit Python dunder names, maintaining consistency with the main bytes class.vm/src/builtins/complex.rs (3)
258-268: LGTM: Arithmetic magic methodsAll arithmetic magic methods (
__abs__,__add__,__sub__,__rsub__,__mul__,__truediv__,__rtruediv__) are correctly renamed to their explicit Python dunder equivalents, following Python's numeric protocol for complex number operations.Also applies to: 287-312, 320-345
347-355: LGTM: Unary and power operationsUnary operations (
__pos__,__neg__) and power operations (__pow__,__rpow__) are correctly renamed to their explicit Python dunder names, maintaining the numeric protocol implementation.Also applies to: 357-378
380-383: LGTM: Type conversion and special methodsType conversion methods (
__bool__,__complex__) and pickling support (__getnewargs__) are correctly renamed to their explicit Python dunder names, completing the comprehensive magic method refactoring for complex numbers.Also applies to: 385-389, 394-401
vm/src/builtins/list.rs (8)
145-148: LGTM: Consistent magic method namingThe renaming from
addto__add__with removal of themagicattribute follows the project's standardization to explicit dunder method names.
160-169: LGTM: Consistent in-place addition method namingThe
__iadd__method renaming and implementation are correct and consistent with the refactoring pattern.
182-185: LGTM: Standard length method implementationThe renaming to
__len__properly exposes Python's length protocol method.
198-204: LGTM: Reversed iterator with updated internal callThe method renaming to
__reversed__and the internal call update on line 200 (zelf.__len__()) are both consistent with the refactoring.
216-219: LGTM: Indexing protocol methods properly renamedThe
__getitem__,__setitem__, and__delitem__method renamings correctly implement Python's indexing protocol.Also applies to: 231-239, 315-318
241-250: LGTM: Multiplication methods consistently renamedBoth
__mul__and__imul__method renamings follow the correct Python dunder naming convention.
404-404: LGTM: Internal calls updated consistentlyAll internal calls to
__len__()in mapping/sequence implementations and repr method are correctly updated to use the new method name.Also applies to: 424-424, 496-496
548-551: LGTM: Iterator methods consistently renamedThe iterator methods
__length_hint__,__setstate__, and__reduce__are properly renamed, and internal calls to__len__()on lines 550, 557, 595, and 602 are correctly updated.Also applies to: 553-558, 593-596, 598-603, 605-610
vm/src/builtins/function.rs (4)
389-401: LGTM: Function attributes consistently renamed to dunder formAll function attributes (
__code__,__defaults__,__kwdefaults__,__name__,__module__,__annotations__,__qualname__,__type_params__) are properly renamed with themagicattribute removed. The setter methods follow the correct naming pattern.Also applies to: 403-410, 435-443, 465-473, 475-483, 485-504, 506-526
148-148: LGTM: Internal calls and error messages updatedAll references to
self.__qualname__()in error messages andself.__name__()in generator/coroutine creation are correctly updated to use the new dunder method names.Also applies to: 183-183, 195-195, 203-203, 260-260, 365-365, 366-366, 367-367
529-539: LGTM: JIT method properly renamedThe
__jit__method renaming is consistent with the refactoring pattern and maintains the correct functionality.
572-572: LGTM: Bound method dunder methods consistently implementedThe
__reduce__,__doc__,__func__,__module__, and__qualname__methods for PyBoundMethod are properly renamed and implemented.Also applies to: 739-748, 750-758, 765-771
vm/src/builtins/object.rs (5)
250-267: LGTM: Comparison methods properly renamedAll comparison methods (
__eq__,__ne__,__lt__,__le__,__ge__,__gt__) are correctly renamed from their magic attribute form to explicit dunder names.Also applies to: 270-287, 290-307
337-341: LGTM: Core object methods consistently renamedThe
__str__,__repr__,__subclasshook__,__init_subclass__,__dir__,__format__, and__init__methods are all properly renamed with themagicattribute removed.Also applies to: 374-377, 379-382, 384-385, 387-390, 392-405, 407-411
138-138: LGTM: Internal calls updated to use dunder methodsThe calls to
slot_names.__len__()on lines 138 and 148 are correctly updated to use the new method name instead of thelen()property.Also applies to: 148-148
347-355: LGTM: Slot repr implementation updatedThe calls to
class.__qualname__(vm)andclass.__module__(vm)are correctly updated to use the new dunder method names.
457-460: LGTM: Attribute and reduction methods renamedThe
__getattribute__,__reduce__,__reduce_ex__,__hash__, and__sizeof__methods are all properly renamed following the consistent pattern.Also applies to: 462-465, 467-479, 487-490, 492-495
vm/src/builtins/bytearray.rs (6)
203-211: LGTM: Core bytearray methods consistently renamedAll core methods (
__alloc__,__len__,__sizeof__,__add__,__contains__,__iadd__,__getitem__,__delitem__) are properly renamed from their magic attribute form to explicit dunder names.Also applies to: 213-216, 218-221, 223-230, 232-242, 244-247, 249-252
548-551: LGTM: Arithmetic and item assignment methods renamedThe
__mul__,__imul__,__rmod__, and__setitem__methods are correctly renamed following the consistent pattern.Also applies to: 553-557, 565-568, 578-586
641-648: LGTM: Pickle protocol methods consistently implementedThe
__reduce_ex__and__reduce__methods are properly renamed, with the internal call on line 647 correctly updated.Also applies to: 650-658
756-756: LGTM: Buffer implementation updatedThe call to
zelf.__len__()in the buffer descriptor creation is correctly updated to use the new method name.
774-776: LGTM: Protocol implementations consistently updatedAll protocol method calls in AsMapping and AsSequence implementations are correctly updated to use the new dunder method names (
__len__(),__getitem__(),__setitem__(),__delitem__(),__contains__(),__iadd__()).Also applies to: 778-778, 783-783, 785-785, 796-796, 825-825, 830-830
894-897: LGTM: Iterator methods consistently renamedThe iterator methods
__length_hint__,__reduce__, and__setstate__are properly renamed, with internal calls to__len__()correctly updated on lines 896 and 909.Also applies to: 898-903, 905-910
stdlib/src/array.rs (11)
910-910: LGTM: Consistent use of dunder method namingThe call to
self.__len__()is consistent with the refactoring to use explicit dunder method names throughout the codebase.
979-987: Excellent refactoring of copy methods to explicit dunder namesThe transformation from
#[pymethod(magic)] fn copyto#[pymethod] fn __copy__and similar for__deepcopy__follows Python's standard magic method conventions. The internal call from__deepcopy__toself.__copy__()is correctly updated.
989-999: Good refactoring of item access methodsThe renaming from
_getitemtogetitem_innerand the explicit__getitem__magic method wrapper follows a clear pattern that separates the internal implementation from the Python-exposed magic method.
1001-1046: Consistent refactoring of setitem implementationThe pattern of renaming internal methods to
*_innerand creating explicit dunder magic method wrappers is applied consistently. The__setitem__method properly delegates tosetitem_inner.
1048-1058: Well-structured delitem refactoringThe same consistent pattern is applied to
delitem- internal logic indelitem_innerwith explicit__delitem__magic method wrapper.
1060-1105: Comprehensive arithmetic method refactoringAll arithmetic magic methods (
__add__,__iadd__,__mul__,__imul__) are consistently renamed from their short forms to explicit dunder names while preserving functionality.
1107-1110: Proper len method conversionThe conversion from
lento__len__maintains thepub(crate)visibility, indicating this method is used both as a Python magic method and internally by the Rust code.
1136-1180: Well-executed pickle method refactoringBoth
__reduce_ex__and__reduce__are properly renamed and the internal call from__reduce_ex__toSelf::__reduce__is correctly updated.
1182-1197: Consistent contains method refactoringThe
containsmethod is properly renamed to__contains__following the same pattern as other magic methods.
1306-1362: Trait implementations correctly updatedAll trait implementations (
AsMappingandAsSequence) are properly updated to use the new method names:__len__(),getitem_inner,setitem_inner,delitem_inner,__add__,__mul__,__contains__,__iadd__, and__imul__.
1395-1407: Iterator methods properly refactoredThe iterator's
__setstate__and__reduce__methods are consistently renamed and the internal call toobj.__len__()is correctly updated.vm/src/builtins/float.rs (6)
207-230: Excellent conversion of format methods to explicit dunder namesBoth
__format__and__getformat__are properly converted from theirmagicattribute forms to explicit dunder method names. The#[pystaticmethod]attribute is correctly used for__getformat__.
232-235: Proper abs method conversionThe
absmethod is correctly renamed to__abs__following Python's magic method conventions.
281-406: Comprehensive arithmetic method refactoringAll arithmetic magic methods are systematically converted to explicit dunder names:
__add__,__bool__,__divmod__,__rdivmod__,__floordiv__,__rfloordiv__,__rmod__,__pos__,__neg__,__pow__,__rpow__,__sub__,__rsub__,__truediv__,__rtruediv__, and__mul__. The functionality is preserved while making the naming explicit.
408-451: Well-executed numeric conversion method refactoringThe numeric conversion and rounding methods (
__trunc__,__floor__,__ceil__,__round__) are consistently renamed to their dunder equivalents while maintaining all the complex rounding logic.
453-461: Correct type conversion method updatesBoth
__int__and__float__are properly renamed, and the internal call in__int__is correctly updated to useself.__trunc__(vm).
512-515: Proper getnewargs method conversionThe
getnewargsmethod is correctly renamed to__getnewargs__following the same pattern as all other magic methods.vm/src/builtins/dict.rs (10)
192-192: LGTM: Consistent method call updateThe call to
__setitem__correctly uses the renamed dunder method name.
205-208: LGTM: Proper magic method renamingThe method is correctly renamed from
lento__len__with themagicattribute removed from the decorator. This makes the Python special method name explicit.
215-218: LGTM: Consistent dunder method implementationThe
__contains__method properly follows the dunder naming convention and removes themagicattribute.
220-223: LGTM: Proper__delitem__implementationThe method is correctly renamed to use the explicit Python dunder name.
230-238: LGTM: Explicit__setitem__methodThe method signature and naming follow Python's data model conventions correctly.
287-296: LGTM: Comprehensive magic method renamingAll the binary operation methods (
__or__,__getitem__,__reversed__,__ior__,__ror__) are properly renamed to their explicit dunder equivalents with consistent decorator updates.Also applies to: 368-372, 392-395, 397-401, 403-412
432-432: LGTM: Updated internal method callsAll internal calls to magic methods are correctly updated to use the new dunder names (
__len__,__or__,__ior__).Also applies to: 466-466, 473-476
743-750: LGTM: DictView trait method updatesThe trait methods
__len__and__reversed__are properly renamed with consistent decorator changes.Also applies to: 778-780
840-843: LGTM: Iterator method renamingThe iterator special methods
__length_hint__and__reduce__are correctly renamed to their dunder equivalents across all iterator classes.Also applies to: 846-858, 916-929, 931-936
1026-1027: LGTM: Set operation methodsAll set operation magic methods (
__xor__,__and__,__or__,__sub__,__rsub__) are properly renamed with themagicattribute removed.Also applies to: 1034-1035, 1042-1043, 1049-1050, 1056-1057
vm/src/builtins/type.rs (10)
479-488: LGTM: Type property getters renamedThe type properties (
__bases__,__base__,__flags__,__basicsize__) are correctly renamed to their explicit dunder equivalents with proper decorator updates.Also applies to: 544-547, 549-552, 554-557
577-592: LGTM:__qualname__property implementationBoth the getter and setter methods for
__qualname__are properly renamed with consistent naming conventions (set___qualname__).Also applies to: 594-620
622-674: LGTM:__annotations__property methodsThe getter and setter methods for
__annotations__follow the correct dunder naming pattern.
676-698: LGTM: Module and class methods renamedThe
__module__,__prepare__, and__subclasses__methods are properly renamed to their dunder equivalents.Also applies to: 700-709, 711-721
723-731: LGTM: Binary operation and dict methodsThe
__ror__,__or__, and__dict__methods are correctly renamed with proper decorator updates.Also applies to: 733-743
761-778: LGTM: Name and signature propertiesThe
set___name__setter and__text_signature__getter are properly renamed following the dunder convention.Also applies to: 780-786
1029-1029: LGTM: Exception handling call updateThe call to
set___cause__correctly uses the renamed exception attribute setter method.
1140-1187: LGTM: Documentation property methodsBoth the
__doc__getter andset___doc__setter are properly implemented with the dunder naming convention.
1189-1212: LGTM: Type introspection methodsThe methods
__dir__,__instancecheck__,__subclasscheck__, and__subclasshook__are correctly renamed to their dunder equivalents.
1292-1292: LGTM: Updated method callsAll internal calls to the renamed methods (
__module__,__qualname__,__basicsize__) are correctly updated.Also applies to: 1301-1301, 1479-1479
vm/src/stdlib/itertools.rs (4)
65-72: LGTM: Excellent systematic refactoring of magic method naming.The renaming of
class_getitemto__class_getitem__and removal of themagicattribute makes the Python special method explicit and aligns perfectly with Python's dunder naming conventions.
74-88: Well-executed standardization of__reduce__method.The explicit naming of the pickle reduction method follows Python conventions perfectly. The logic remains unchanged while improving code readability and explicitness.
90-119: Consistent and correct__setstate__implementation.The renaming maintains the exact same functionality while making the pickle state restoration method explicitly named according to Python standards.
204-210: Comprehensive and systematic magic method standardization.This refactoring systematically renames all Python special methods across multiple iterator classes to their canonical dunder forms:
reduce→__reduce__setstate→__setstate__length_hint→__length_hint__copy→__copy__The changes are consistent, maintain all existing functionality, and significantly improve code explicitness by removing the
magicattribute flag in favor of explicit Python dunder naming conventions.Also applies to: 277-280, 398-415, 477-483, 542-560, 629-647, 966-993, 1063-1069, 1133-1182, 1306-1312, 1393-1443, 1528-1554, 1769-1775, 1882-1904
vm/src/builtins/set.rs (5)
545-548: Excellent systematic refactoring of PySet magic methods.The comprehensive renaming of magic methods to their canonical Python dunder forms significantly improves code explicitness:
len→__len__contains→__contains__or→__or__and→__and__sub→__sub__reduce→__reduce__class_getitem→__class_getitem__All functionality is preserved while removing the implicit
magicattribute in favor of explicit Python naming conventions.Also applies to: 562-565, 607-618, 621-636, 638-653, 655-670, 673-688, 717-721, 741-746, 754-759, 772-777, 779-785, 787-790
810-810: Well-updated trait implementations with new dunder method calls.The AsSequence and AsNumber trait implementations have been properly updated to call the new dunder method names (e.g.,
a.__sub__(...),a.__and__(...), etc.), maintaining consistency with the renamed methods.Also applies to: 844-844, 851-851, 858-858, 865-865, 872-872, 880-880, 888-888, 896-896
971-974: Consistent refactoring applied to PyFrozenSet.The same systematic approach is correctly applied to PyFrozenSet, ensuring consistency across both mutable and immutable set implementations. All magic methods follow the same dunder naming pattern.
Also applies to: 994-997, 1039-1050, 1053-1068, 1070-1085, 1087-1103, 1106-1121, 1123-1129, 1131-1134
1140-1140: Proper trait implementation updates for PyFrozenSet.The AsSequence and AsNumber trait implementations for PyFrozenSet are correctly updated to use the new dunder method names, maintaining consistency with the PySet implementation.
Also applies to: 1197-1197, 1204-1204, 1211-1211, 1218-1218
1305-1308: Complete coverage with PySetIterator updates.The refactoring extends to PySetIterator with proper
__length_hint__and__reduce__method naming, ensuring comprehensive coverage of all Python special methods in the set module.Also applies to: 1310-1327
vm/src/stdlib/typing.rs (6)
72-156: LGTM: Proper conversion to explicit dunder method namingThe systematic conversion of magic methods to explicit dunder names is correctly implemented:
#[pymethod(magic)]→#[pymethod]#[pygetset(magic)]→#[pygetset]- Method names explicitly use dunder notation (e.g.,
__mro_entries__,__name__,__reduce__)This aligns with Python's data model and improves code clarity.
347-461: LGTM: Consistent dunder method naming for ParamSpecThe conversion follows the same correct pattern as other classes, with proper removal of
magicattributes and explicit dunder method naming.
575-578: LGTM: Correct dunder method naming for NoDefaultThe
__reduce__method conversion is properly implemented.
612-667: LGTM: TypeVarTuple dunder method conversionAll method renamings and decorator updates are correctly applied following the established pattern.
748-836: LGTM: ParamSpecArgs and ParamSpecKwargs dunder methodsThe conversion of
__mro_entries__and__origin__methods follows the correct pattern with proper decorator updates.
932-939: LGTM: Generic class method conversionThe
__class_getitem__class method is correctly converted to explicit dunder naming while maintaining the proper#[pyclassmethod]decorator.vm/src/builtins/int.rs (5)
324-481: LGTM: Arithmetic method conversion to explicit dunder namingThe systematic conversion of arithmetic methods (
__add__,__sub__,__mul__,__truediv__, etc.) correctly removesmagicattributes and uses explicit dunder method names. The pattern is consistent throughout all arithmetic operations.
484-586: LGTM: Special method conversionAll unary and special methods are correctly converted to explicit dunder naming with proper decorator updates.
548-548: LGTM: Internal method call updatesThe internal calls are correctly updated to use the new dunder method names (
__int__) instead of the old plain names (int), maintaining consistency with the renamed methods.Also applies to: 553-553, 558-558, 563-563, 600-600, 669-669, 679-679
694-697: LGTM:__getnewargs__method conversionThe conversion follows the established pattern correctly.
702-708: LGTM: PyRef implementation consistencyThe
__int__method in the PyRef implementation is correctly updated to maintain consistency with the overall dunder method naming pattern.
bef21a3 to
ece5c75
Compare
ece5c75 to
3673372
Compare
Better interface for users of RustPython as library and AI programming models.
Summary by CodeRabbit
__len__,__getitem__,__name__) across built-in types, standard library modules, and exception handling.__enter__,__exit__) and other protocol methods renamed accordingly.magicattribute in documentation.These updates unify the Python interface naming, improve clarity, and maintain compatibility without changing functionality visible to end-users.