[Python] Calling Python Functions from Java (Without Jython, because it is too slow.)

Discussão em 'Python' iniciado por Stack, Julho 16, 2025.

  1. Stack

    Stack Membro Participativo

    I need to be able to call Python functions from Java, and get the return of those functions, which should be primitives only.
    I also don't need to access Java objects in Python or other stuff like that.
    But, most of all, I need speed. I need to be able to load the script at the start of my application and then call some functions at different time-intervals, which can sometimes get really tiny (30-40 times per second).
    That's the main-reason why I don't think that Jython will work for me: It has all kinds of stuff that I don't need, and is incredibly slow.

    So, those are the constraints/requirements I have:

    • Needs to be fast
    • I need to call python functions and get their result
    • The script should be loaded only once

    Do you guys know about another way to simply call Python functions in a pre-loaded script (So that the script does not have to be loaded again and again for each function call)?

    (PS: I do not think that this is a duplicate as I searched quite a lot and all links I found did not answer my question (For example Calling Python in Java?) )

    Continue reading...

Compartilhe esta Página