On 28/02/2014 11:48 AM, James Powell wrote:
There's a catch here: Python 2 and Python 3 use the same C APIs, so you'd have to separate the two in some way to make both live in the same process. I actually have a working embedding of Python 3 into Python 2, which I've presented at a few conferences, most recently at PyData London this past weekend.
It's just a C-extension module that embeds a Python 3 PyRun_SimpleString. I haven't gotten around to building a shim to interact with Python 3 objects in Python 2 (and this would require a little bit of sophistication to handle GIL, GC, &c. issues.)
Still, it's a working example of Python 2 and Python 3 running in the same process. I don't know if this idea has any serious applications. It's definitely been a fun toy for presenting ideas about interpreter embedding and exploring certain facets of CPython!
Cheers, James Powell
James, I would suggest there is a very significant application for for calling python 2 objects from python3, in that suddenly the main roadblock to migration to python 3, the dependency on legacy python2 modules, could be removed as a roadblock. Certainly well worth working through the issues. Ian