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

Function main

misc/profile_check.py:99–141  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97
98
99def main() -> None:
100 check_requirements()
101
102 parser = argparse.ArgumentParser(
103 description="Compile mypy and profile type checking using 'perf' (by default, self check)."
104 )
105 parser.add_argument(
106 "--multi-file",
107 action="store_true",
108 help="compile mypy into one C file per module (to reduce RAM use during compilation)",
109 )
110 parser.add_argument(
111 "--skip-compile", action="store_true", help="use compiled mypy from previous run"
112 )
113 parser.add_argument(
114 "-c",
115 metavar="CODE",
116 default=None,
117 type=str,
118 help="profile type checking Python code fragment instead of mypy self-check",
119 )
120 args = parser.parse_args()
121 multi_file: bool = args.multi_file
122 skip_compile: bool = args.skip_compile
123 code: str | None = args.c
124
125 target_dir = TARGET_DIR
126
127 if not skip_compile:
128 clone(target_dir, "HEAD")
129
130 print(f"Building mypy in {target_dir}...")
131 build_mypy(target_dir, multi_file, cflags=CFLAGS)
132 elif not os.path.isdir(target_dir):
133 sys.exit("error: Can't find compile mypy from previous run -- can't use --skip-compile")
134
135 profile_type_check(target_dir, code)
136
137 print()
138 print('NOTE: Compile CPython using CFLAGS="-O2 -g -fno-omit-frame-pointer" for good results')
139 print()
140 print("CPU profile collected. You can now analyze the profile:")
141 print(f" perf report -i {target_dir}/perf.data ")
142
143
144if __name__ == "__main__":

Callers 1

profile_check.pyFile · 0.70

Calls 8

cloneFunction · 0.90
build_mypyFunction · 0.90
check_requirementsFunction · 0.85
printFunction · 0.85
profile_type_checkFunction · 0.85
add_argumentMethod · 0.80
exitMethod · 0.80
isdirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…