Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property functions (getter and setter) of memory in class Memory superfluous #148

Open
skleber opened this issue Oct 18, 2018 · 0 comments

Comments

@skleber
Copy link
Contributor

skleber commented Oct 18, 2018

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant