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

Calling function with large string parameter blocks forever #70

Open
James4Ever0 opened this issue Dec 10, 2022 · 1 comment
Open

Calling function with large string parameter blocks forever #70

James4Ever0 opened this issue Dec 10, 2022 · 1 comment

Comments

@James4Ever0
Copy link

James4Ever0 commented Dec 10, 2022

To demonstrate this problem, the following code is used:

# saying you have a large html file called "target.html"
from javascript import require
JSDOM = require("jsdom").JSDOM
filepath = "target.html"

with open(filepath,"r") as f:
    html = f.read()
    dom = JSDOM(html) # the step taking forever
    print("dom loaded?", dom)

I can only get this working by writing this in javascript and read the file in the js script, only return the final result to python.

@James4Ever0 James4Ever0 changed the title calling function with large string parameter blocks forever Calling function with large string parameter blocks forever Dec 10, 2022
@mara004
Copy link
Contributor

mara004 commented Nov 19, 2023

I believe is for the same reason as #67 (comment) / #103 (comment), just with the opposite direction. JSON serialization isn't suitable to transfer big binary data.

PR #103 proposes a new transfer strategy that would fix the Js -> Py direction. Something similar will be needed for Py -> Js. And I suppose pythonia will be affected as well and equally require a bidirectional fix.

However, note that it will still be more performant to produce data natively in the language where it's needed and avoid transferring big values if you can help it, for even though the transfer can be made much more efficient, it will always add some overhead. This is because Js/Py are separate processes that do not share the same memory, but have to communicate over a pipe instead.

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

2 participants