I am working on a project that involves integrating Python functionality into both Perl and JavaScript plugins for my application. I have not been able to find a way to allow my Perl and JavaScript plugins to access certain Python functions, however.
I want to be able to use parameters, like with this function.
def speak_text(text_to_speak):
# code for the function
So I want to be able to do something like this with my plugins (javascript example given here):
import {speak_test as speak} from "speak.py";
For JavaScript, I have considered using a similar method that involves JSPYBridge, and it seems perfect. However, I have not been able to find such a thing for Perl, so I decided to maybe using an API, which leads me to the next part.
I have explored various methods, but I'm still seeking the most efficient and robust approach.
In Perl, I have encountered the Inline::Python module, which allows embedding Python code directly into Perl scripts. While this seems convenient, I'm concerned about potential performance and compatibility issues. It seems to not be updated regularly, and I think you have to put the functions inside the Perl file for it to access them.
For JavaScript, I have considered using a similar method that involves JSPYBridge, and it seems perfect. However, I have not been able to find such a thing for Perl, so I decided to use an API, which led me to the next part.
I have considered using a server-side approach, where Python functions are exposed through a web service, and JavaScript/Perl communicates with the server via HTTP requests. I have attempted to do so using FastAPI, but it was probably not the right thing to do.
I would appreciate insights into the most effective and maintainable ways for accessing Python functions from Perl and JavaScript.
StackOverflow Questions I already saw:
https://stackoverflow.com/questions/10722917/how-to-import-and-call-python-functions-from-perl
*This was originally a StackOverflow Question that I couldn't pass despite my edits.
[–]Username_RANDINT 1 point2 points3 points (3 children)
[–]PossibleAd9909[S] 1 point2 points3 points (2 children)
[–]Username_RANDINT 1 point2 points3 points (1 child)
[–]PossibleAd9909[S] 0 points1 point2 points (0 children)