Skip to content

Commit b564636

Browse files
committed
Fix #84 - Provide enough details behind the PyScript project and stack
1 parent fc4b706 commit b564636

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

docs/user-guide/behind-pyscript.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Behind PyScript
2+
3+
There are various projects that make PyScript possible and it's probably worth exploring each project responsibility to help both users and contributors to land both issues or feature requests in the right place.
4+
5+
## Polyscript
6+
7+
The [polyscript project](https://github.com/pyscript/polyscript#readme) purpose is to enable any runtime / programming language able to interface itself with *JS* through the *WASM* browsers native API.
8+
9+
The scope of this project can be summarized as such:
10+
11+
* provide as little as possible abstraction to bootstrap different interpreters (Pyodide, MicroPython, R, Lua, Ruby, others ...)
12+
* simplify the bootstrap of any interpreter through DOM primitives (script, custom-elements, or both ...)
13+
* understand and parse any explicit configuration option (being this a file to parse or an already parsed object literal)
14+
* forward any defined **hook** to the interpreter so that code before, or right after, can be transparently executed
15+
* orchestrate a single bootstrap per each involved element, being this a script or a `<custom-script>` on the living page
16+
* ensure a *Worker*, optionally *Atomics* and *SharedArrayBuffer* based, stand-alone environment can be bootstrapped and available for at least not experimental runtime (Lua, Ruby, [others](https://pyscript.github.io/polyscript/#interpreter-features))
17+
18+
While this is a simplification of all the things polyscript does behind the scene, the rule of thumb to "*blame*" *polyscript* for anything affecting your project/idea is likely:
19+
20+
* is my interpreter not loading?
21+
* where are errors around my interpreter not loading?
22+
* is my *HTML* event not triggering? (`py-*` or `mpy-*` or ...)
23+
* how come this feature handled explicitly by *polyscript* is not reflected in my *PyScript* project? (this is likely and advanced issue/use case, but it's always OK to ask *why* in polyscript, and answers will flow accordingly)
24+
25+
To summarize, as much as *PyScript* users should never encounter one of these issues, it is possible some specific feature request or issue might be enabled in polyscript first to land then in PyScript.
26+
27+
## Coincident
28+
29+
At the core of *polyscript* project there is one extra project enabling all the seamless worker to main, and vice-versa, features called [coincident](https://github.com/WebReflection/coincident#readme).
30+
31+
The purpose of this project is to enable, in a memory / garbage collector friendly way, a communication channel between one thread and another, handling the main thread dealing with workers references, or the other way around, as its best core feature.
32+
33+
Anything strictly related to *SharedArrayBuffer* issues is then an orchestration *coincident* is handling, and to some extend also anything memory leak related could as well fall down to this module purpose and scope.
34+
35+
In a nutshell, this project takes care of, and is responsible for, the following patterns:
36+
37+
* invoking something from a worker that refers the main thread somehow fails
38+
* there is a reproducible and cross platform (browsers) memory leak to tackle
39+
* some function invoke with some specific argument from a worker doesn't produce the expected result
40+
41+
All these scenarios are unlikely to happen with *PyScript* project, as these are all battle tested and covered with such general purpose cross-env/realm oriented project way before landing in *PyScript*, but if you feel something is really off, leaking, or badly broken, please feel free to file an issue in this project and, once again, there is never a silly question about it so that, as long as you can provide any minimal reproducible issue, all questions and issues are more than welcome!
42+

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ nav:
8080
- Plugins: user-guide/plugins.md
8181
- Use Offline: user-guide/offline.md
8282
- Example apps: user-guide/examples.md
83+
- Behind PyScript: user-guide/behind-pyscript.md

0 commit comments

Comments
 (0)