3 ms·
"With only a few lines of code we have written a C program that fires up a PyPy interpreter and runs our Python code as if it was a native C function. Of course
by kensai 10y ago
"With only a few lines of code we have written a C program that fires up a PyPy interpreter and runs our Python code as if it was a native C function. Of course I've only shown you the basics here, but the technology is really powerful."
So, C speed with Python semantics?
- guipsp 10y agoScripting apis are a possible use too.
- thedjinn 10y agoYes indeed, and using this approach you can also write Python plugins for other applications if they don't have Python scripting support already.
- noahdesu 10y agoIn the article, after the pypy plugin.py step that produced the C library, one could presumably dlopen the library to accomplish a dynamic plugin feature. Is there a way to invoke pypy to JIT this code to avoid invoking pypy and a compiler?
- thedjinn 10y agoThe way I understand it is that on first invocation of a function exported in the library this function will spin up a regular PyPy interpreter, which does JIT in exactly the same way as a normal invocation of PyPy would.
- scandinavian 10y ago"So, C speed with Python semantics?" That's already what PyPy is, isn't it? (Not really C speed, but the method in the article is just calling the PyPy interpreter, so it's not quite C speed anyway.)