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

Function precompute_set_literal

mypyc/irbuild/expression.py:894–908  ·  view source on GitHub ↗

Try to pre-compute a frozenset literal during module initialization. Return None if it's not possible. Supported items: - Anything supported by irbuild.constant_fold.constant_fold_expr() - None, True, and False - Tuple literals with only items listed above

(builder: IRBuilder, s: SetExpr)

Source from the content-addressed store, hash-verified

892
893
894def precompute_set_literal(builder: IRBuilder, s: SetExpr) -> Value | None:
895 """Try to pre-compute a frozenset literal during module initialization.
896
897 Return None if it's not possible.
898
899 Supported items:
900 - Anything supported by irbuild.constant_fold.constant_fold_expr()
901 - None, True, and False
902 - Tuple literals with only items listed above
903 """
904 values = set_literal_values(builder, s.items)
905 if values is not None:
906 return builder.add(LoadLiteral(frozenset(values), set_rprimitive))
907
908 return None
909
910
911def transform_comparison_expr(builder: IRBuilder, e: ComparisonExpr) -> Value:

Callers 2

make_for_loop_generatorFunction · 0.90
try_specialize_in_exprFunction · 0.85

Calls 4

LoadLiteralClass · 0.90
set_literal_valuesFunction · 0.85
frozensetClass · 0.85
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…