[pypy-dev] Exposing rpython based functions to cpython vm.

Aleksandr Koshkin tinysnippets at gmail.com
Mon Jun 19 18:36:03 EDT 2017


Thank you guys for your responses, appreciated.
So as a study case I am building custom JIT powered regex matcher (somewhat
more or less compatible with pcre). It is not a problem to build one as a
stand alone application but I want it as a shared library and ultimately as
a python compatible module. As a interface between rpython (C, really) and
python for input I see a tuple - (program::bytes, input_string::unicode)
and for output [(group0::unicode, value0::unicode), ..., ].
1. Is it even a sane idea to use rpython toolchain to handle such task? I
mean specifically embedding problem, because again as a stand alone app it
is not a big deal and worth nothing.
2. Why some valid rpython code fails inside a function decorated with an
entrypoint_highlevel (e.g. os.write(1, "hello world") would fail with
segfault at runtime). And are there any dedicated docs describing such
limitations?
Cheers, magniff.

2017-06-19 22:55 GMT+03:00 Yury V. Zaytsev <yury at shurup.com>:

> On Mon, 19 Jun 2017, Armin Rigo wrote:
>
> Answered on https://stackoverflow.com/questions/44629893/invoke-rpython-
>> based-functions-from-standard-python-code
>>
>
> I would add to that that in the case that the idea was to take some code
> out of hot loops, translate it into RPython so that it runs faster, and
> finally import it into cPython, then (as Armin elaborated) you're missing
> the point of RPython. However, here are few alternatives to consider:
>
> One go-to solution would be to use Cython which lets you easily blend
> Python / C up to the point of writing restricted C with Python syntax, and
> import resulting Cython modules into your program running under cPython.
>
> A more principled solution would be to port your application to PyPy (if
> any porting would be required at all), and enjoy the JIT, or else dig
> around trying to figure out why exactly is that you're not getting the
> speedups you were hoping for, and make PyPy better in the process!
>
> --
> Sincerely yours,
> Yury V. Zaytsev
>



-- 
Kind regards, Aleksandr Koshkin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20170620/5e6f15aa/attachment-0001.html>


More information about the pypy-dev mailing list