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

Function buf_init_item

mypyc/lower/list_ops.py:16–39  ·  view source on GitHub ↗

Initialize an item in a buffer of "PyObject *" values at given index. This can be used to initialize the data buffer of a freshly allocated list object.

(builder: LowLevelIRBuilder, args: list[Value], line: int)

Source from the content-addressed store, hash-verified

14
15@lower_primitive_op("buf_init_item")
16def buf_init_item(builder: LowLevelIRBuilder, args: list[Value], line: int) -> Value:
17 """Initialize an item in a buffer of "PyObject *" values at given index.
18
19 This can be used to initialize the data buffer of a freshly allocated list
20 object.
21 """
22 base = args[0]
23 index_value = args[1]
24 value = args[2]
25 assert isinstance(index_value, Integer), index_value
26 index = index_value.numeric_value()
27 if index == 0:
28 ptr = base
29 else:
30 ptr = builder.add(
31 IntOp(
32 pointer_rprimitive,
33 base,
34 Integer(index * PLATFORM_SIZE, c_pyssize_t_rprimitive),
35 IntOp.ADD,
36 line,
37 )
38 )
39 return builder.add(SetMem(object_rprimitive, ptr, value, line))
40
41
42@lower_primitive_op("list_items")

Callers

nothing calls this directly

Calls 6

IntOpClass · 0.90
IntegerClass · 0.90
SetMemClass · 0.90
isinstanceFunction · 0.85
numeric_valueMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…