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

Improve wrapping #28

Closed
Helveg opened this issue Jul 2, 2020 · 1 comment · Fixed by #38
Closed

Improve wrapping #28

Helveg opened this issue Jul 2, 2020 · 1 comment · Fixed by #38

Comments

@Helveg
Copy link
Collaborator

Helveg commented Jul 2, 2020

Currently whether an object should be wrapped is determined every function call:

    def __getattr__(self, attr_name):
        # Get the missing attribute from h, if it requires wrapping return a wrapped
        # object instead.
        attr = getattr(self.__h, attr_name)
        if attr_name in self.__requires_wrapping:
            return self.wrap(attr, attr_name)
        else:
            return attr

This can be improved by overriden the PythonHocInterpreter at the end of its instantiation for all things that should be wrapped and don't override the function already.

@Helveg
Copy link
Collaborator Author

Helveg commented Oct 6, 2020

To allow subclasses of the PythonHocObject classes to be created both before and after the PythonHocInterpreter class has been created and still wrap all of them I think this approach is best:

  • In __init_subclass__ add the new hoc object class to a list on the interpreter.
  • In the interpreter class store a weakrefs to every interpreter.
  • Create wrappers when interpreter is created.
  • Add wrappers to every interpreter when a class is created.

Helveg added a commit that referenced this issue Oct 11, 2020
* Added init_subclass that registers a wrapper in the PythonHocInterpreter

* Improved the PythonHocInterpreter's HocObject wrapping. closes #28
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

Successfully merging a pull request may close this issue.

1 participant