Skip to content

Navigation Menu

Sign in
Sign up

Some other python library shares the same objective ? #160

Answered by wiwichips
GabCores asked this question in Q&A
Discussion options

Describe your feature request here.

Hi , I have beeb working with this library for a while
https://pypi.org/project/javascript/

it is stable and wide open functional project
Is there anyone else who knows about it, and what are the ways in which this project surpasses or adds to the functions of the other already established project?

Thanks in advance

Code example

No response

You must be logged in to vote

Hey @GabCores,

JsPyBridge (or "javascript" on pypi) is a similar project to PythonMonkey but has several differences in its implementation and API:

Most notably, under the hood JsPyBridge runs a separate nodejs process which communicates with the user's Python process. This comes with a severe performance penalty as data is copied whenever passed. PythonMonkey passes data by reference whenever possible meaning the cost of transferring information between Python and JavaScript is almost zero. Since references are copied, modifying data passed from Python into JavaScript (or vice versa) will not change the original reference in JsPyBridge but will as expected in JavaScript.

Here is a snippe...

Replies: 2 comments 3 replies

Comment options

Hey @GabCores,

JsPyBridge (or "javascript" on pypi) is a similar project to PythonMonkey but has several differences in its implementation and API:

Most notably, under the hood JsPyBridge runs a separate nodejs process which communicates with the user's Python process. This comes with a severe performance penalty as data is copied whenever passed. PythonMonkey passes data by reference whenever possible meaning the cost of transferring information between Python and JavaScript is almost zero. Since references are copied, modifying data passed from Python into JavaScript (or vice versa) will not change the original reference in JsPyBridge but will as expected in JavaScript.

Here is a snippet relating to the interprocess communication from their README for reference:

On the bridge to call JavaScript from Python, due to the limiatations of Python and cross-platform IPC, we currently communicate over standard error which means that JSON output in JS standard error can interfere with the bridge. The same issue exists on Windows with python. You are however very unlikely to have issues with this.

Regarding API, PythonMonkey works nicely with Python's asyncio library for running JavaScript promises giving developers a familiar experience using async and await keyword in Python whereas JsPyBridge implements its own method for this by decorating functions.

JsPyBridge is an impressive project but PythonMonkey takes a different approach and therefore has different pros and cons. For instance, at the moment PythonMonkey lacks the Node.js support JsPyBridge has out of the box (but that will change in the future as it is just in Alpha at the moment)!

Hope this helps! Thanks for checking our our project and asking this question!!! (:

You must be logged in to vote
3 replies
Comment options

Any scope of bringing fetch api in PythonMonkey ?

Comment options

Hey @almahdi404 , adding fetch to PythonMonkey is a good idea and very doable - I created a feature request to track it #161

I'll leave the ticket open now for external contributors but we might not get to it for some time. That being said if you're looking for alternatives, you should be able to use the requests from Python library in JavaScript using PythonMonkey

Comment options

great, i am actually building a ssr framework using solidjs and django.
am currently using JSPyBridge, trying to migrate to PythonMonkey.

I really appreciate this project. ❤️

Answer selected by Xmader
Comment options

XHR is in active development right now and even be in the mainline by the time you read this. There are fetch polyfills implemented in terms of XHR, so if you need this, it's probably pretty close to being ready.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #159 on August 03, 2023 21:33.

AltStyle によって変換されたページ (->オリジナル) /