MCPcopy Index your code
hub / github.com/python/mypy / generate_slots

Function generate_slots

mypyc/codegen/emitclass.py:177–193  ·  view source on GitHub ↗
(cl: ClassIR, table: SlotTable, emitter: Emitter)

Source from the content-addressed store, hash-verified

175
176
177def generate_slots(cl: ClassIR, table: SlotTable, emitter: Emitter) -> dict[str, str]:
178 fields: dict[str, str] = {}
179 generated: dict[str, str] = {}
180 # Sort for determinism on Python 3.5
181 for name, (slot, generator) in sorted(table.items(), key=lambda x: slot_key(x[0])):
182 method_cls = cl.get_method_and_class(name)
183 if method_cls and (method_cls[1] == cl or name in ALWAYS_FILL):
184 if slot in generated:
185 # Reuse previously generated wrapper.
186 fields[slot] = generated[slot]
187 else:
188 # Generate new wrapper.
189 name = generator(cl, method_cls[0], emitter)
190 fields[slot] = name
191 generated[slot] = name
192
193 return fields
194
195
196def generate_class_type_decl(

Callers 1

generate_classFunction · 0.85

Calls 4

sortedFunction · 0.85
slot_keyFunction · 0.85
get_method_and_classMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…