[Python-ideas] A python bridge between versions
M.-A. Lemburg
mal at egenix.com
Fri Feb 28 10:16:34 CET 2014
More information about the Python-ideas mailing list
Fri Feb 28 10:16:34 CET 2014
- Previous message: [Python-ideas] A python bridge between versions
- Next message: [Python-ideas] A python bridge between versions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 28.02.2014 01:48, James Powell wrote: > On 02/27/2014 06:51 PM, M.-A. Lemburg wrote: >> On 28.02.2014 00:26, ian o wrote: >>> [... Embed Python 2 in Python 3 ...] >>> >>> Thoughts or criticisms? > >> 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. Interesting :-) Do you have some pointers to slides or videos ? I'm been thinking of doing something like this but the other way around - embed Python2 in Python3. When starting to brainstorm that idea, I quickly ended up postponing the idea again due to problems with C extension linking, dual interpreter environments, object interfacing between the two worlds, having two separate exception class trees, two sets of basic types/classes, two GILs, etc. The linking part was the most important to me, since being able to use Python 2 extensions would be my main reason to stick with Python 2 for some more time. >> It's not impossible, but it can potentially ruin the idea, since >> C extensions for both Python versions will have to link the right >> set of C APIs. > > I did this by "source filtering" - i.e., rewriting exported symbols to > allow linking against both interpreters. This is admittedly a very > primitive approach and limits its use in production. > > I recently put some time into trying to redo this embedding using cffi > and worked through a few problems in this approach with one of the > cython/numba developers. I haven't gotten anything working yet. I may > need to ask Xzibit if he has any suggestions. > > 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 > > follow: @dontusethiscode + @nycpython > attend: nycpython.org > read: seriously.dontusethiscode.com Cheers, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Feb 28 2014) >>> Python Projects, Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::::: Try our mxODBC.Connect Python Database Interface for free ! :::::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/
- Previous message: [Python-ideas] A python bridge between versions
- Next message: [Python-ideas] A python bridge between versions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list