-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize reuse of Pyodide object again
- Loading branch information
1 parent
c91c3df
commit e5c533d
Showing
6 changed files
with
114 additions
and
57 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import { loadPyodide } from "pyodide"; | ||
|
||
export const getPythonRuntime = ( | ||
repoURL: string, | ||
onStdout: (x: string) => void, | ||
onStderr: (x: string) => void | ||
) => | ||
loadPyodide({ | ||
export const getPythonRuntime = async (repoURL: string) => { | ||
const pyodide = await loadPyodide({ | ||
indexURL: repoURL, | ||
stdout: onStdout, | ||
stderr: onStderr, | ||
homedir: "/home/user", | ||
}); | ||
await pyodide.runPythonAsync(` | ||
from js import prompt | ||
def input(p): | ||
return prompt(p) | ||
__builtins__.input = input | ||
`); | ||
return pyodide; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters