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

Function as_platform_int

mypyc/irbuild/vec.py:60–73  ·  view source on GitHub ↗
(builder: LowLevelIRBuilder, v: Value, line: int)

Source from the content-addressed store, hash-verified

58
59
60def as_platform_int(builder: LowLevelIRBuilder, v: Value, line: int) -> Value:
61 rtype = v.type
62 if is_c_py_ssize_t_rprimitive(rtype):
63 return v
64 if isinstance(v, Integer):
65 if is_short_int_rprimitive(rtype) or is_int_rprimitive(rtype):
66 return Integer(v.value // 2, c_pyssize_t_rprimitive)
67 return Integer(v.value, c_pyssize_t_rprimitive)
68 if isinstance(rtype, RPrimitive):
69 if PLATFORM_SIZE == 8 and is_int64_rprimitive(rtype):
70 return v
71 if PLATFORM_SIZE == 4 and is_int32_rprimitive(rtype):
72 return v
73 return builder.coerce(v, c_pyssize_t_rprimitive, line)
74
75
76def vec_create(

Callers 6

vec_from_iterableFunction · 0.90
vec_createFunction · 0.85
vec_create_initializedFunction · 0.85
vec_get_item_unsafeFunction · 0.85
vec_init_item_unsafeFunction · 0.85
vec_popFunction · 0.85

Calls 8

is_short_int_rprimitiveFunction · 0.90
is_int_rprimitiveFunction · 0.90
IntegerClass · 0.90
is_int64_rprimitiveFunction · 0.90
is_int32_rprimitiveFunction · 0.90
isinstanceFunction · 0.85
coerceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…