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

Function get_expr_length_value

mypyc/irbuild/for_helpers.py:1347–1357  ·  view source on GitHub ↗
(
    builder: IRBuilder, expr: Expression, expr_reg: Value, line: int, use_pyssize_t: bool
)

Source from the content-addressed store, hash-verified

1345
1346
1347def get_expr_length_value(
1348 builder: IRBuilder, expr: Expression, expr_reg: Value, line: int, use_pyssize_t: bool
1349) -> Value:
1350 rtype = builder.node_type(expr)
1351 assert is_sequence_rprimitive(rtype) or isinstance(rtype, (RTuple, RVec)), rtype
1352 length = get_expr_length(builder, expr)
1353 if length is None:
1354 # We cannot compute the length at compile time, so we will fetch it.
1355 return builder.builder.builtin_len(expr_reg, line, use_pyssize_t=use_pyssize_t)
1356 # The expression result is known at compile time, so we can use a constant.
1357 return Integer(length, c_pyssize_t_rprimitive if use_pyssize_t else short_int_rprimitive)

Callers 2

translate_lenFunction · 0.90

Calls 6

is_sequence_rprimitiveFunction · 0.90
IntegerClass · 0.90
isinstanceFunction · 0.85
get_expr_lengthFunction · 0.85
node_typeMethod · 0.80
builtin_lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…