netzob
netzob copied to clipboard
Property functions (getter and setter) of memory in class Memory superfluous
The getter and setter functions of the property __memory in class Model.Vocabulary.Domain.Variables.Memory.Memory (see below) are dysfunctional: They expose the internal property __memory in such a way so that the getters and setter become superfluous. In case of the setter it makes it even inefficient, since it copies the dict instead of referencing it.
If copying was intended behaviour, this should be documented. In this case, a more efficient way of doing this would be to replace the complete function body by either:
self.__memory = dict(memory) or self.__memory = memory.copy()
Snippet of the referred functions in Model.Vocabulary.Domain.Variables.Memory.Memory:
@property
def memory(self):
"""The content of the memory is stored in this dict().
:type: :class:`dict`
"""
return self.__memory
@memory.setter
def memory(self, memory):
self.__memory = dict()
for k, v in list(memory.items()):
self.__memory[k] = v