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

Function vec_create_initialized

mypyc/irbuild/vec.py:146–175  ·  view source on GitHub ↗

Create vec with items initialized to the given value.

(
    builder: LowLevelIRBuilder,
    vtype: RVec,
    length: int | Value,
    init: Value,
    line: int,
    *,
    capacity: Value | None = None,
)

Source from the content-addressed store, hash-verified

144
145
146def vec_create_initialized(
147 builder: LowLevelIRBuilder,
148 vtype: RVec,
149 length: int | Value,
150 init: Value,
151 line: int,
152 *,
153 capacity: Value | None = None,
154) -> Value:
155 """Create vec with items initialized to the given value."""
156 if isinstance(length, int):
157 length = Integer(length, c_pyssize_t_rprimitive)
158 length = as_platform_int(builder, length, line)
159
160 item_type = vtype.item_type
161 init = builder.coerce(init, item_type, line)
162 vec = vec_create(builder, vtype, length, line, capacity=capacity)
163
164 items_start = vec_items(builder, vec)
165 step = step_size(item_type)
166 items_end = builder.int_add(items_start, builder.int_mul(length, step))
167
168 for_loop = builder.begin_for(
169 items_start, items_end, Integer(step, c_pyssize_t_rprimitive), signed=False
170 )
171 vec_set_mem_item(builder, for_loop.index, item_type, init)
172 for_loop.finish()
173
174 builder.keep_alive([vec], line)
175 return vec
176
177
178def vec_create_from_values(

Callers 1

Calls 13

IntegerClass · 0.90
isinstanceFunction · 0.85
as_platform_intFunction · 0.85
vec_createFunction · 0.85
vec_itemsFunction · 0.85
step_sizeFunction · 0.85
vec_set_mem_itemFunction · 0.85
int_addMethod · 0.80
int_mulMethod · 0.80
begin_forMethod · 0.80
keep_aliveMethod · 0.80
coerceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…