Great! Thanks very much for this post, Yury.
I'll do just what you suggested. :)
Cheers,
Etienne
Le 2018-01-28 à 07:35, Yury V. Zaytsev a écrit :
> On Sun, 28 Jan 2018, Etienne Robillard wrote:
>
>>> Anyways, having that said, I can't even infer what your original
>>> line of thinking was to embed what into what to speed up what
>>> exactly...
>>>
>> I'm looking to use JIT as a replacement for Cython in a upcoming
>> Django-hotsauce release. :)
>
> If this is indeed your goal, then I do have some good news for you:
> you don't have to do anything at all other than scraping Cython in
> order to achieve it. Just run your code on PyPy instead of CPython and
> you will benefit directly from PyPy's tracing JIT.
>
> To answer the question of why do you have to scrape Cython before it
> comes up: you *can* run Cython compiled modules on top of PyPy thanks
> to its Python C API emulation layer (CPyExt). However, this will be
> inefficient because (a) crossing PyPy / C boundary is slow, although
> not as slow as it used to be in the past and (b) PyPy's JIT can't see
> into machine code created from Cython-generated C/C++ source code.
> Therefore, to benefit most from PyPy you'd better feed it pure Python
> code.
>
>>> Once you translate a Django app into C code (let's assume this is
>>> actually possible for the sake of the argument) and then compile it
>>> into machine code using clang there is nothing more left for a JIT
>>> to operate upon, because machine code is interpreted directly by the
>>> CPU.
>>
>> I'm really sure its possible to generate a C or C++ file from
>> human-generated Python code.
>
> In that case, you have to educate yourself, and specifically try to
> understand how Cython really works. Hint: generating C/C++ file from
> Python code != translate Python code into C/C++ code that doesn't
> require CPython runtime.
>
>> So far, I want to use the LLVM backend (PyPy)
>
> PyPy doesn't have anything to do with LLVM at this point. There have
> been multiple attempts in the past to use LLVM as backend for PyPy,
> but so far none of them have really been succesful, where success is
> defined as making it a default backend.
>
>> to translate CPython classes into a tracing JIT compiler...
>
> This statement is devoid of meaning.
>
>> I'm positive you can use PyPy in embedded C/C++ applications to
>> enable trace compilation of Python objects.
>>
>> JIT is cool because it can theoretically makes Django and Python web
>> apps outperform C applications.
>
> These statements are both correct, but see the beginning of this email.