MCPcopy Index your code
hub / github.com/python/mypy / _encode_str_values

Function _encode_str_values

mypyc/codegen/literals.py:174–192  ·  view source on GitHub ↗
(values: dict[str, int])

Source from the content-addressed store, hash-verified

172
173
174def _encode_str_values(values: dict[str, int]) -> list[bytes]:
175 value_by_index = {index: value for value, index in values.items()}
176 result = []
177 line: list[bytes] = []
178 line_len = 0
179 for i in range(len(values)):
180 value = value_by_index[i]
181 c_literal = format_str_literal(value)
182 c_len = len(c_literal)
183 if line_len > 0 and line_len + c_len > 70:
184 result.append(format_int(len(line)) + b"".join(line))
185 line = []
186 line_len = 0
187 line.append(c_literal)
188 line_len += c_len
189 if line:
190 result.append(format_int(len(line)) + b"".join(line))
191 result.append(b"")
192 return result
193
194
195def _encode_bytes_values(values: dict[bytes, int]) -> list[bytes]:

Callers 2

encoded_str_valuesMethod · 0.85

Calls 7

rangeClass · 0.85
lenFunction · 0.85
format_str_literalFunction · 0.85
format_intFunction · 0.85
appendMethod · 0.80
itemsMethod · 0.45
joinMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…