We should stop using pyodide.ffi, maybe? #1952
Replies: 4 comments 7 replies
-
My 2c. TL;DR: Consistency is a good thing for folks using PyScript. Using unique workarounds depending on which Python interpreter you choose or need to use is not a great situation. It calcifies code and makes it brittle depending on the Python interpreter. It reminds me of the IE6-only problems we had in the mid-00s. I'm very much in the "write once, run everywhere" camp. I hope our ongoing conversations about the FFI will help us move forward. We've got this. No matter how we proceed, our usual modus operandi of careful steps, respectful technical explorations and a collaborative frame of mind are key. We've got this, along with our Pyodide and MicroPython friends. cc/ @hoodmane @dpgeorge |
Beta Was this translation helpful? Give feedback.
-
I don't have concrete input to offer here on which functions we should replace/rename/shadow in the Pyodide FFI, but I'm +1 to having a layer of indirection between the PyScript "FFI" and the underlying interpreters. If there are functions that we really find useful enough that we're recommending users import from pyodide, we should shadow them in the PyScript module - which also givens us more flexibility to adapt them for different interpreters. That said, then it's on us to provide documentation that is as-good-or-better than what's offered upstream. |
Beta Was this translation helpful? Give feedback.
-
Adding my +1 to adding an abstraction layer for all the reasons listed above. We may be able to remove some of that later (as @WebReflection showed recently, we can add some things to help quite transparently) but for now it's definitely needed. I've had to do some of that internally when adding support for MicroPython in |
Beta Was this translation helpful? Give feedback.
-
I'm no where near as expert in pyscript and web as the others on this thread, but I came across this issue as I was trying to figure out how to run some code (just learning how to use pyscript) in micropython after writing it in pyodide. I am curious what is the current workaround for the lack of certain apis being availabe in micropython (if any). For example, I am using Also I notice that |
Beta Was this translation helpful? Give feedback.
-
We currently have PyWeb (or PyDom) broken in MicroPython and the reason is almost always the same: we use specific pyodide APIs that we don't get to control neither in Pyodide space nor MicroPython.
This is, imho, pretty bad for cross-portability of our own code but it's also ugly to me that anyone in MicroPython needs to import stuff from pyodide.ffi + various APIs or tricks needed in Pyodide are not really needed in MicroPython (or not reflected).
Currenty we are using:
pyodide.ffi.to_js
which is nowhere in MicroPython but most of the time not even neededpyodide.ffi.JsProxy
which is also nowhere in MicroPython but that couples identities/references to a namespace they don't necessarily belong to neither and it's all a pyodide implementation detail our users shouldn't really care aboutpyodide.wrappers.add_event_listener
which is also nowhere in MicroPython but also apparently never needed and, if thecreate_proxy = "auto"
lands in polyscript, it won't ever be needed even in pyodideI am here suggesting we provide a
to_js
and a utility to check if a reference comes from the JS world, such asis_js(ref)
that would abstract away the need to ever import anything from pyodide namespace and will make both our code and our users code easier to reason about, as all they do is to import utilities frompyscript
module, not random names leaked in other runtimes.What do you think?
/cc @ntoll @fpliger @antocuni
Beta Was this translation helpful? Give feedback.
All reactions