Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion mypyc/codegen/emitclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ def native_slot(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str:
return f"{NATIVE_PREFIX}{fn.cname(emitter.names)}"


def wrapper_slot(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str:
"""Use a generated wrapper function directly as a slot, without boxing its result."""
return f"{NATIVE_PREFIX}{fn.cname(emitter.names)}"


def dunder_attr_slot(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str:
wrapper_fn = cl.get_method(fn.name + "__wrapper")
assert wrapper_fn
Expand All @@ -88,7 +93,7 @@ def dunder_attr_slot(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str:
"__getattr__": ("tp_getattro", dunder_attr_slot),
# The wrapper is also generated for a class that defines only __delattr__, so fill
# the slot based on the wrapper instead of __setattr__.
"__setattr____wrapper": ("tp_setattro", native_slot),
"__setattr____wrapper": ("tp_setattro", wrapper_slot),
}

AS_MAPPING_SLOT_DEFS: SlotTable = {
Expand Down
Loading