MCPcopy Index your code
hub / github.com/python/cpython / Ratio

Class Ratio

Tools/scripts/summarize_stats.py:148–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146
147@dataclass(frozen=True)
148class Ratio:
149 num: int
150 den: int | None = None
151 percentage: bool = True
152
153 def __float__(self):
154 if self.den == 0:
155 return 0.0
156 elif self.den is None:
157 return self.num
158 else:
159 return self.num / self.den
160
161 def markdown(self) -> str:
162 if self.den is None:
163 return ""
164 elif self.den == 0:
165 if self.num != 0:
166 return f"{self.num:,} / 0 !!"
167 return ""
168 elif self.percentage:
169 return f"{self.num / self.den:,.01%}"
170 else:
171 return f"{self.num / self.den:,.02f}"
172
173
174class DiffRatio(Ratio):

Callers 11

calcFunction · 0.70
calc_pair_count_tableFunction · 0.70
calc_deferred_by_tableFunction · 0.70
calc_misses_by_tableFunction · 0.70
calc_call_stats_tableFunction · 0.70
calc_object_stats_tableFunction · 0.70
calc_optimization_tableFunction · 0.70
calc_optimizer_tableFunction · 0.70
calc_jit_memory_tableFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…