diff --git a/README.md b/README.md index cd1e51af8..427f69c17 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,8 @@ web-based notebook environment for literate scientific computing and communication. Iodide is no longer maintained. If you want to use Pyodide in an interactive -client-side notebook, see [Pyodide Notebook -environments](https://pyodide.org/en/0.17.0a2/project/related-projects.html#notebook-environements-ides-repls). +client-side notebook, see [Pyodide notebook +environments](https://pyodide.org/en/0.17.0a2/project/related-projects.html#notebook-environments-ides-repls). ## Contributing diff --git a/docs/usage/faq.md b/docs/usage/faq.md index def37effd..9653ab419 100644 --- a/docs/usage/faq.md +++ b/docs/usage/faq.md @@ -101,7 +101,7 @@ if platform.system() == 'Emscripten': This however will not work at build time (i.e. in a `setup.py`) due to the way the Pyodide build system works. It first compiles packages with the host compiler (e.g. gcc) and then re-runs the compilation commands with emsdk. So the `setup.py` is -never run inside the Pyodide environement. +never run inside the Pyodide environment. To detect Pyodide, **at build time** use, ```python @@ -144,3 +144,26 @@ assert my_js_module.f(7) == 50 assert h(9) == 80 assert c == 2 ``` +## How can I send a Python object from my server to Pyodide? + +The best way to do this is with pickle. If the version of Python used in the +server exactly matches the version of Python used in the client, then objects +that can be successfully pickled can be sent to the client and unpickled in +Pyodide. If the versions of Python are different then for instance sending AST +is unlikely to work since there are breaking changes to Python AST in most +Python minor versions. + +Similarly when pickling Python objects defined in a Python package, the package +version needs to match exactly between the server and pyodide. + +Generally, pickles are portable between architectures (here amd64 and wasm32). +The rare cases when they are not portable, for instance currently tree based +models in scikit-learn, can be considered as a bug in the upstream library. + +```{admonition} Security Issues with pickle +:class: warning + +Unpickling data is similar to `eval`. On any public-facing server it is a really +bad idea to unpickle any data sent from the client. For sending data from client +to server, try some other serialization format like JSON. +```