Skip to content

Commit 7e79c4a

Browse files
authored
Micro-optimize cache deserialization (fixup) (#18303)
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.
1 parent fadb308 commit 7e79c4a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mypy/fixup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ def visit_type_info(self, info: TypeInfo) -> None:
117117
# NOTE: This method *definitely* isn't part of the NodeVisitor API.
118118
def visit_symbol_table(self, symtab: SymbolTable, table_fullname: str) -> None:
119119
# Copy the items because we may mutate symtab.
120-
for key, value in list(symtab.items()):
120+
for key in list(symtab):
121+
value = symtab[key]
121122
cross_ref = value.cross_ref
122123
if cross_ref is not None: # Fix up cross-reference.
123124
value.cross_ref = None

0 commit comments

Comments
 (0)