securesystemslab / zippy

ZipPy is a Python3 interpreter on top of Truffle framework
BSD 3-Clause "New" or "Revised" License
300 stars 22 forks source link

Question regarding compatibility #3

Open AshwinRamesh opened 7 years ago

AshwinRamesh commented 7 years ago

Hi guys,

First of all, great work on what you guys are trying to accomplish!!

My question comes regarding this issue on Bitbucket: https://bitbucket.org/ssllab/zippy/issues/4/things-that-are-missing-in-zippy

Are these modules still not supported under zippy?

Regards,

Ash

qunaibit commented 7 years ago

Hi,

Thank you!

The modules you are referring to in the list list are still uncovered and we are happy to accept pull requests to support them.

Cheers,

SemanticBeeng commented 7 years ago

@qunaibit - thank you, this will be very useful as it supports the need to migrate Python to things like Apache Spark.

I am considering using this for a project https://github.com/SemanticBeeng/The_Termolator which I am looking to migrate to Spark.

Could Zippy be used to as a stepping stone by running a mix of ported (Java/Scala) code and Python as is. This could be a good strategy given the lack of familiarity with the code base. I could port incrementally.

Since it is all on the JVM this should be ... workable but the interpreter must be tread safe. Jep is not: https://github.com/mrj0/jep/wiki/How-Jep-Works#threading-complications

Is the Zippy interpreter thread safe (no thread state/affinity, etc)?

Thoughts in general about this idea please?

qunaibit commented 7 years ago

Hi,

Currently, ZipPy doesn't support a mixture of Java and Python. ZipPy rely on Jython's parser to build the AST (Abstract Syntax Tree), and since Jython uses threads to do the process, we can't guarantee thread safety.

Best,

SemanticBeeng commented 7 years ago

Understood it does not support the mix. But after Python is parsed (once) and ready for execution (many times) is there anything not thread safe? Or is it only up to Truffle / Graal runtime?

Found this https://github.com/graalvm/graal/blob/master/examples/src/org.graalvm.polyglot.examples/src/org/graalvm/polyglot/examples/ParallelEval.java#L11-L12

Example shows how scripts can be executed in parallel. Please note that contexts are single threaded by design. It is allowed to use a context on more than one thread, but not at the same time.

Which would suggest it is like Jep.

Once all it is JVM bytecode (from Java or Python) they overall program should run well together, no? My implicit assumption it that there is a way to use Zippy to translate to bytecode and then run that on the JVM without having to re-parse / analyze more than once.

Kindly advise. Thanks

qunaibit commented 7 years ago

But after Python is parsed (once) and ready for execution (many times) is there anything not thread safe? Or is it only up to Truffle / Graal runtime?

In this case, it should be fine for multiple Threads.

Once all it is JVM bytecode (from Java or Python) they overall program should run well together, no? My implicit assumption it that there is a way to use Zippy to translate to bytecode and then run that on the JVM without having to re-parse / analyze more than once.

The only way, I can think of at the moment, is that you build your own internal library in Java and call it from your Python program. e.g. Math library and register the library here.

Best,

SemanticBeeng commented 7 years ago

@qunaibit how is the Python 3 implemented; heard you are using Jython but that does not support Python 3 does it?

https://bitbucket.org/ssllab/zippy - "ZipPy is a fast and lightweight Python 3 implementation "

More specifically, does zippy support typing? See this for context https://gitter.im/python/typing?at=596f47af329651f46ea11f04 https://www.python.org/dev/peps/pep-0484/#rationale-and-goals

Thanks in advance.

qunaibit commented 7 years ago

how is the Python 3 implemented; heard you are using Jython but that does not support Python 3 does it? https://bitbucket.org/ssllab/zippy - "ZipPy is a fast and lightweight Python 3 implementation "

We use Jython primarily as a parser, so some Python 3 features are not available yet. Once Jython 3 reaches a beta stage we will replace the current Jython jar and support the other Python 3 features.

More specifically, does zippy support typing? See this for context https://gitter.im/python/typing?at=596f47af329651f46ea11f04 https://www.python.org/dev/peps/pep-0484/#rationale-and-goals

Typing isn't supported, yet, in ZipPy

Best