Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Don't generate redundant slots tables
  • Loading branch information
JukkaL committed Jul 30, 2025
commit ce60137d7548b4151ef58dab89ced6abbb1b7f42
9 changes: 7 additions & 2 deletions mypyc/codegen/emitmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,13 @@ def generate_module_def(self, emitter: Emitter, module_name: str, module: Module
module_prefix = emitter.names.private_name(module_name)
self.emit_module_methods(emitter, module_name, module_prefix, module)
self.emit_module_exec_func(emitter, module_name, module_prefix, module)
if self.multi_phase_init:

# The slots table is only created here when using multi-phase init but
# not a shared library. If using a shared library, the slots tables will
# be included in shim modules instead.
if self.multi_phase_init and not self.use_shared_lib:
self.emit_module_def_slots(emitter, module_prefix, module_name)

self.emit_module_def_struct(emitter, module_name, module_prefix)
self.emit_module_init_func(emitter, module_name, module_prefix)

Expand Down Expand Up @@ -969,7 +974,7 @@ def emit_module_def_struct(
"0, /* size of per-interpreter state of the module */",
f"{module_prefix}module_methods,",
)
if self.multi_phase_init:
if self.multi_phase_init and not self.use_shared_lib:
slots_name = f"{module_prefix}_slots"
emitter.emit_line(f"{slots_name}, /* m_slots */")
else:
Expand Down