MCPcopy Create free account
hub / github.com/ZeroIntensity/pointers.py / _get_chunk_at

Method _get_chunk_at

src/pointers/calloc.py:66–86  ·  view source on GitHub ↗
(self, index: int)

Source from the content-addressed store, hash-verified

64 return self._chunks
65
66 def _get_chunk_at(self, index: int) -> "AllocatedArrayPointer[T]":
67 if index > self.chunks:
68 raise IndexError(
69 f"index is {index}, while allocation is {self.chunks}",
70 )
71
72 if index < 0: # for handling __sub__
73 raise IndexError("index is below zero")
74
75 if index not in self._chunk_store:
76 self._chunk_store[index] = AllocatedArrayPointer(
77 self._origin_address + (index * self.size),
78 self.chunks,
79 self.size,
80 index,
81 self._chunk_store,
82 self._freed,
83 self._origin_address,
84 )
85
86 return self._chunk_store[index]
87
88 def __add__(self, amount: int) -> "AllocatedArrayPointer[T]":
89 self.ensure_valid()

Callers 4

__add__Method · 0.95
__getitem__Method · 0.95
__setitem__Method · 0.95
freeMethod · 0.95

Calls 1

Tested by

no test coverage detected