MCPcopy Create free account
hub / github.com/python/mypy / finalize

Method finalize

mypyc/irbuild/classdef.py:288–313  ·  view source on GitHub ↗
(self, ir: ClassIR)

Source from the content-addressed store, hash-verified

286 )
287
288 def finalize(self, ir: ClassIR) -> None:
289 # Dynamically create the class via the type constructor
290 non_ext_class = load_non_ext_class(self.builder, ir, self.non_ext, self.cdef.line)
291 non_ext_class = load_decorated_class(self.builder, self.cdef, non_ext_class)
292
293 # Try to avoid contention when using free threading.
294 self.builder.set_immortal_if_free_threaded(non_ext_class, self.cdef.line)
295
296 # Save the decorated class
297 self.builder.add(
298 InitStatic(non_ext_class, self.cdef.name, self.builder.module_name, NAMESPACE_TYPE)
299 )
300
301 # Add the non-extension class to the dict
302 self.builder.call_c(
303 exact_dict_set_item_op,
304 [
305 self.builder.load_globals_dict(),
306 self.builder.load_str(self.cdef.name),
307 non_ext_class,
308 ],
309 self.cdef.line,
310 )
311
312 # Cache any cacheable class attributes
313 cache_class_attrs(self.builder, self.attrs_to_cache, self.cdef)
314
315
316class ExtClassBuilder(ClassBuilder):

Callers 1

transform_class_defFunction · 0.95

Calls 9

InitStaticClass · 0.90
load_non_ext_classFunction · 0.85
load_decorated_classFunction · 0.85
cache_class_attrsFunction · 0.85
load_globals_dictMethod · 0.80
addMethod · 0.45
call_cMethod · 0.45
load_strMethod · 0.45

Tested by

no test coverage detected