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

Don't destroy roundtrip PyProxies automatically #3369

Merged
merged 6 commits into from Dec 23, 2022

Commits on Dec 18, 2022

  1. Don't destroy roundtrip PyProxies automatically

    There's a bunch of places where we want to destroy a `PyProxy` if it is being
    handed back into Python. This way, if the user wants to keep the proxy around
    they can return a copy() of it (whereas otherwise they would have no way to
    destroy it after the JavaScript execution is ended).
    
    ```js
    function new_dict(){
      const dict = pyodide.globals.get("dict");
      const result = dict([[1,2],[3,4]]);
      return result;
      // Proxy is destroyed after it is returned!
    }
    ```
    
    If the `PyProxy` has roundtrip set, however, it is generally a bad idea to
    destroy it in these cases. In many cases, this means that the object returned
    to Python is actually unusable (because we get a destroyed double proxy).
    
    One slightly annoying question is how to deal with the case where (1) we
    want the return value NOT to be destroyed and (2) it may or may not be roundtrip
    
    ```
    function f(px){
       // We don't want px to be destroyed so we have to return a copy (the copy
       // gets destroyed instead). But if px is roundtrip then the copy is also
       // roundtrip and neither gets destroyed so there is a leak. What to do???
       return px.copy();
    }
    hoodmane committed Dec 18, 2022
    Copy the full SHA
    b3f972a View commit details
    Browse the repository at this point in the history
  2. Fix ReferenceError

    hoodmane committed Dec 18, 2022
    Copy the full SHA
    c5bbaf9 View commit details
    Browse the repository at this point in the history

Commits on Dec 21, 2022

  1. Copy the full SHA
    ad918da View commit details
    Browse the repository at this point in the history
  2. Add test

    hoodmane committed Dec 21, 2022
    Copy the full SHA
    c73337c View commit details
    Browse the repository at this point in the history
  3. Update changelog

    hoodmane committed Dec 21, 2022
    Copy the full SHA
    8804c8a View commit details
    Browse the repository at this point in the history

Commits on Dec 22, 2022

  1. Copy the full SHA
    27312b9 View commit details
    Browse the repository at this point in the history