File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -1278,14 +1278,14 @@ pub(crate) fn vectorcall_function(
12781278 // FAST PATH: simple positional-only call, exact arg count.
12791279 // Move owned args directly into fastlocals — no clone needed.
12801280 let locals = if code. flags . contains ( bytecode:: CodeFlags :: NEWLOCALS ) {
1281- ArgMapping :: from_dict_exact ( vm . ctx . new_dict ( ) )
1281+ None // lazy allocation — most frames never access locals dict
12821282 } else {
1283- ArgMapping :: from_dict_exact ( zelf. globals . clone ( ) )
1283+ Some ( ArgMapping :: from_dict_exact ( zelf. globals . clone ( ) ) )
12841284 } ;
12851285
12861286 let frame = Frame :: new (
12871287 code. to_owned ( ) ,
1288- Scope :: new ( Some ( locals) , zelf. globals . clone ( ) ) ,
1288+ Scope :: new ( locals, zelf. globals . clone ( ) ) ,
12891289 zelf. builtins . clone ( ) ,
12901290 zelf. closure . as_ref ( ) . map_or ( & [ ] , |c| c. as_slice ( ) ) ,
12911291 Some ( zelf. to_owned ( ) . into ( ) ) ,
Original file line number Diff line number Diff line change @@ -144,6 +144,8 @@ impl FuncArgs {
144144 nargs : usize ,
145145 kwnames : Option < & [ PyObjectRef ] > ,
146146 ) -> Self {
147+ debug_assert ! ( nargs <= args. len( ) ) ;
148+ debug_assert ! ( kwnames. is_none_or( |kw| nargs + kw. len( ) <= args. len( ) ) ) ;
147149 let pos_args = args[ ..nargs] . to_vec ( ) ;
148150 let kwargs = if let Some ( names) = kwnames {
149151 names
@@ -173,6 +175,8 @@ impl FuncArgs {
173175 nargs : usize ,
174176 kwnames : Option < & [ PyObjectRef ] > ,
175177 ) -> Self {
178+ debug_assert ! ( nargs <= args. len( ) ) ;
179+ debug_assert ! ( kwnames. is_none_or( |kw| nargs + kw. len( ) <= args. len( ) ) ) ;
176180 let kwargs = if let Some ( names) = kwnames {
177181 let kw_count = names. len ( ) ;
178182 names
You can’t perform that action at this time.
0 commit comments