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

Class RArray

mypyc/ir/rtypes.py:1207–1248  ·  view source on GitHub ↗

Fixed-length C array type (for example, int[5]). Note that the implementation is a bit limited, and these can basically be only used for local variables that are initialized in one location.

Source from the content-addressed store, hash-verified

1205
1206@final
1207class RArray(RType):
1208 """Fixed-length C array type (for example, int[5]).
1209
1210 Note that the implementation is a bit limited, and these can basically
1211 be only used for local variables that are initialized in one location.
1212 """
1213
1214 def __init__(self, item_type: RType, length: int) -> None:
1215 self.item_type = item_type
1216 # Number of items
1217 self.length = length
1218 self.is_refcounted = False
1219
1220 def accept(self, visitor: RTypeVisitor[T]) -> T:
1221 return visitor.visit_rarray(self)
1222
1223 @property
1224 def may_be_immortal(self) -> bool:
1225 return False
1226
1227 def __str__(self) -> str:
1228 return f"{self.item_type}[{self.length}]"
1229
1230 def __repr__(self) -> str:
1231 return f"<RArray {self.item_type!r}[{self.length}]>"
1232
1233 def __eq__(self, other: object) -> TypeGuard[RArray]:
1234 return (
1235 isinstance(other, RArray)
1236 and self.item_type == other.item_type
1237 and self.length == other.length
1238 )
1239
1240 def __hash__(self) -> int:
1241 return hash((self.item_type, self.length))
1242
1243 def serialize(self) -> JsonDict:
1244 assert False
1245
1246 @classmethod
1247 def deserialize(cls, data: JsonDict, ctx: DeserMaps) -> RArray:
1248 assert False
1249
1250
1251PyObject = RStruct(

Callers 8

setup_rarrayMethod · 0.90
test_basicsMethod · 0.90
test_str_conversionMethod · 0.90
test_eqMethod · 0.90
test_hashMethod · 0.90
test_alignmentMethod · 0.90
test_sizeMethod · 0.90
test_assign_multiMethod · 0.90

Calls

no outgoing calls

Tested by 7

test_basicsMethod · 0.72
test_str_conversionMethod · 0.72
test_eqMethod · 0.72
test_hashMethod · 0.72
test_alignmentMethod · 0.72
test_sizeMethod · 0.72
test_assign_multiMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…