fix vector to be usable in deepcopy

This commit is contained in:
Danny Ryan 2019-03-19 10:57:40 -06:00
parent 9e3079854f
commit ff165c197b
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
1 changed files with 14 additions and 7 deletions

View File

@ -39,15 +39,22 @@ def SSZType(fields):
return SSZObject return SSZObject
class Vector(list): class Vector():
def __init__(self, x): def __init__(self, items):
list.__init__(self, x) self.items = items
self.length = len(x) self.length = len(items)
def append(*args): def __getitem__(self, key):
raise Exception("Cannot change the length of a vector") return self.items[key]
remove = clear = extend = pop = insert = append def __setitem__(self, key, value):
self.items[key] = value
def __iter__(self):
return iter(self.items)
def __len__(self):
return self.length
def is_basic(typ): def is_basic(typ):