Add per-type vectorcall for builtin constructors#7407
Add per-type vectorcall for builtin constructors#7407youknowone wants to merge 2 commits intoRustPython:mainfrom
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan for PR comments
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. Comment |
Add vectorcall dispatch in vectorcall_type to check each type's own slots.vectorcall before falling back to PyType::call. Only dispatch when slots.call is None, to avoid misinterpreting callable-instance vectorcalls (e.g. vectorcall_function) as constructor vectorcalls. Clear vectorcall when __init__ or __new__ is overridden in update_slot to ensure subclass correctness. Implement per-type vectorcall for 12 builtin types: - Pattern A (skip args.clone): dict, set, list, bytearray - Pattern B (skip dispatch): int, float, str, bool, tuple, frozenset, bytes, complex
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/poplib.py dependencies:
dependent tests: (1 tests)
Legend:
|
Pattern B vectorcall functions now call through zelf.slots.new instead of calling PyXxx::slot_new directly. This ensures Rust-level subclasses with custom slot_new (e.g. stat_result subclassing tuple) get their own constructor called correctly. Fix PyStatResult::slot_new to use struct_sequence_new for proper length validation and hidden field padding, matching structseq_new behavior. Derive st_atime/st_mtime/st_ctime and their _ns variants from integer time fields when not explicitly provided.
close #7362
Add vectorcall dispatch in vectorcall_type to check each type's own slots.vectorcall before falling back to PyType::call. Clear vectorcall when init or new is overridden in update_slot to ensure subclass correctness.
Implement per-type vectorcall for 12 builtin types: