Possible Duplicate:
Java Python Integration
There is some code written in Python and I need to use it from Scala. The code uses some native C. Is it possible to use this from Scala or Java without having to rewrite much?
I intend to use the code as a black-box without understanding, so I prefer not to look into it but rather to somehow generate a jar that I can import in my code.
Performance. When it comes to performance, Scala is the clear winner over Python. One reason Scala wins on performance is that it is a statically typed programming language and Python is a dynamically typed programming language. With statically typed languages, the compiler knows each variable or expression at runtime.
It works from the command line because the shell is parsing and interpreting the string before invoking the python command. In the Scala code the ProcessBuilder is trying to parse and interpret the string without the shell's help. We can help the interpreting. This should work.
Scala allows writing of code with multiple concurrency primitives whereas Python doesn't support concurrency or multithreading. Due to its concurrency feature, Scala allows better memory management and data processing. However Python does support heavyweight process forking.
PerformanceScala, a compiled language, is seen as being approximately 10 times faster than an interpreted Python because the source code is translated to efficient machine representation before the runtime.
Why not try Jython?You directly compile python code to Java classes or call Python code from Java through interface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With