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

Function list_item_ptr

mypyc/lower/list_ops.py:48–64  ·  view source on GitHub ↗

Get a pointer to a list item (index must be valid and non-negative). Type of index must be c_pyssize_t_rprimitive, and obj must refer to a list object.

(builder: LowLevelIRBuilder, obj: Value, index: Value, line: int)

Source from the content-addressed store, hash-verified

46
47
48def list_item_ptr(builder: LowLevelIRBuilder, obj: Value, index: Value, line: int) -> Value:
49 """Get a pointer to a list item (index must be valid and non-negative).
50
51 Type of index must be c_pyssize_t_rprimitive, and obj must refer to a list object.
52 """
53 # List items are represented as an array of pointers. Pointer to the item obj[index] is
54 # <pointer to first item> + index * <pointer size>.
55 items = list_items(builder, [obj], line)
56 delta = builder.add(
57 IntOp(
58 c_pyssize_t_rprimitive,
59 index,
60 Integer(PLATFORM_SIZE, c_pyssize_t_rprimitive),
61 IntOp.MUL,
62 )
63 )
64 return builder.add(IntOp(pointer_rprimitive, items, delta, IntOp.ADD))
65
66
67@lower_primitive_op("list_get_item_unsafe")

Callers 1

list_get_item_unsafeFunction · 0.85

Calls 4

IntOpClass · 0.90
IntegerClass · 0.90
list_itemsFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…