5efaf73271
FossilOrigin-Name: 36c77bdca28143d6a2928f9ea2b9dbb4003ef9e48fd61cddac0897af6f888e74
18 lines
401 B
Python
18 lines
401 B
Python
import os
|
|
import struct
|
|
|
|
|
|
class Memory(list):
|
|
def __init__(self, source, size):
|
|
m = [0] * size
|
|
self.extend(m)
|
|
cells = int(os.path.getsize(source) / 4)
|
|
f = open(source, "rb")
|
|
i = 0
|
|
for cell in list(struct.unpack(cells * "i", f.read())):
|
|
self[i] = cell
|
|
i = i + 1
|
|
f.close()
|
|
|
|
def size(self):
|
|
return len(self)
|