Skip to content

Commit

Permalink
Micro-optimize cache deserialization (fixup) (#18303)
Browse files Browse the repository at this point in the history
Mypyc is bad at compiling tuple unpacking, so this should be faster,
based on a microbenchmark I created. Also fewer tuple objects need to be
allocated and freed.

The impact is probably too small to be measured in a real workload, but
every little helps.
  • Loading branch information
JukkaL authored Dec 18, 2024
1 parent fadb308 commit 7e79c4a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mypy/fixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def visit_type_info(self, info: TypeInfo) -> None:
# NOTE: This method *definitely* isn't part of the NodeVisitor API.
def visit_symbol_table(self, symtab: SymbolTable, table_fullname: str) -> None:
# Copy the items because we may mutate symtab.
for key, value in list(symtab.items()):
for key in list(symtab):
value = symtab[key]
cross_ref = value.cross_ref
if cross_ref is not None: # Fix up cross-reference.
value.cross_ref = None
Expand Down

0 comments on commit 7e79c4a

Please sign in to comment.