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

Function _encode_complex_values

mypyc/codegen/literals.py:287–301  ·  view source on GitHub ↗

Encode float values into a C array values. The result contains the number of values followed by pairs of doubles representing complex numbers.

(values: dict[complex, int])

Source from the content-addressed store, hash-verified

285
286
287def _encode_complex_values(values: dict[complex, int]) -> list[str]:
288 """Encode float values into a C array values.
289
290 The result contains the number of values followed by pairs of doubles
291 representing complex numbers.
292 """
293 value_by_index = {index: value for value, index in values.items()}
294 result = []
295 num = len(values)
296 result.append(str(num))
297 for i in range(num):
298 value = value_by_index[i]
299 result.append(float_to_c(value.real))
300 result.append(float_to_c(value.imag))
301 return result

Callers 1

Calls 6

lenFunction · 0.85
strClass · 0.85
rangeClass · 0.85
float_to_cFunction · 0.85
appendMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…