A
A
afiskon2011-04-28 16:47:59
Python
afiskon, 2011-04-28 16:47:59

A few questions for Python experts?

I must say right away that I do not write in Python.
Once I read about Jython and IronPython. Still, are these interpreters implemented on the JVM/.NET, respectively, Python translators to Java/C#, or compilers to code for the JVM and .NET? To be more precise, I’m interested in whether it is possible to write one application in Python so that it works equally well on Android, iOS and Windows Phone and does not require the user to install additional interpreters and virtual machines.
That was question number 1. Question number 2 - do Python's compilers (named above and Cython) or interpreters (CPython) implement automatic program parallelism and lazy evaluation? In my opinion, these are the most interesting features provided by the functional paradigm. Or is everything limited to banal map/grep and fast work on multi-core processors is not to be expected?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
susl, 2011-04-29
@afiskon

1) IronPython is not exactly an interpreter, although it is closer to it than to a compiler. It "compiles" python into DLR trees, which are then JIT compiled and modified (not trees, contexts) as they run. In general, even the first versions were faster than CPython honed over the years only due to this. But even C# does not come close to the level of performance.
IronPython can be used on Windows Phone, you only need to pull 2 ​​dlls with you. On Android, as far as I know, you also need to embed Python. And on iOS, it seems to be completely forbidden to use interpreted languages, but I didn’t understand this, so there may be nuances :)
One application for 3 such different platforms will be difficult anyway, the entire interface will have to be rewritten, and on mobile devices the interface itself will there are 80% of the application.
2) I have not seen automatic parallelization in any implementation, and not quite a python is suitable for this. In addition, CPython has its own problems with parallelism at the thread level :)
With lazy, I don’t quite understand what you are asking, the language is not call-by-name/call-by-need. Eager evaluation seems to imply that there is no laziness. But, as in any language with closure support, you can safely implement what needs to be implemented, for example, a simple decorator that wraps the desired method and makes a call only when necessary.
In addition, there are generators and itertools - essentially lazy work with threads in python.

M
MikhailEdoshin, 2011-04-28
@MikhailEdoshin

I'm not an expert, but as far as I understand 1) these are interpreters, there is only one compiler - Cython; 2a) there is no automatic parallelization, there is generally a global lock on the interpreter; 2b) lazy calculations, in principle, can be done with generators; in general, on multi-core processors, Python will not automatically speed up, or even slow down.

R
retran, 2011-04-28
@retran

IronPython has no problems with parallelization, GIL does not.

S
Sergey Lerg, 2011-04-28
@Lerg

IronPython is a complete implementation of python for .Net, it works very well, you can use it.
I don’t know about Windows Phone, but on Android and iOS you can upload your program with the Python interpreter already installed in it (via the library).
There is no automatic parallelization in CPython.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question