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

Function _encode_bytes_values

mypyc/codegen/literals.py:195–213  ·  view source on GitHub ↗
(values: dict[bytes, int])

Source from the content-addressed store, hash-verified

193
194
195def _encode_bytes_values(values: dict[bytes, int]) -> list[bytes]:
196 value_by_index = {index: value for value, index in values.items()}
197 result = []
198 line: list[bytes] = []
199 line_len = 0
200 for i in range(len(values)):
201 value = value_by_index[i]
202 c_init = format_int(len(value))
203 c_len = len(c_init) + len(value)
204 if line_len > 0 and line_len + c_len > 70:
205 result.append(format_int(len(line)) + b"".join(line))
206 line = []
207 line_len = 0
208 line.append(c_init + value)
209 line_len += c_len
210 if line:
211 result.append(format_int(len(line)) + b"".join(line))
212 result.append(b"")
213 return result
214
215
216def format_int(n: int) -> bytes:

Callers 2

encoded_bytes_valuesMethod · 0.85

Calls 6

rangeClass · 0.85
lenFunction · 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…