Add per-type vectorcall for builtin constructors by youknowone · Pull Request #7407 · RustPython/RustPython
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters