import ctypes provides low-level arrays class dynamicarray """ dynamic array class akin to simplified python list "" def init (self) """create an empty array ""count actual elements self default array capacity self capacity low-level array self self make array(self capacity def len (self) """return number of elements stored in the array "" return self def getitem (selfk) """return element at index "" if not < self raise indexerrorinvalid index retrieve from array return self [ def append(selfobj) """add object to end of the array ""not enough room if self =self capacityso double capacity self resize( self capacity self [self nobj self + nonpublic utitity def resize(selfc) """resize internal array to capacity ""new (biggerarray self make array(cfor each existing value for in range(self ) [kself [kuse the bigger array self self capacity nonpublic utitity def make array(selfc) """return new array with capacity ""see ctypes documentation return ( ctypes py object)code fragment an implementation of dynamicarray classusing raw array from the ctypes module as storage