[C++-sig] boost::python for Python 3.0
Dear all: I would like to know if there is any progress on the development of a version of boost::python for Python 3.0, the last activity that I can track on this is back to the first days of April; that includes mailing lists and the boost repository. I played a little with it and last night I succeeded in compiling boost::python for Python 3.0 and in running the first test (test_builtin_converters.py), but of course a lot have still to be done (the const char* and char* issue, among many ones...). I would like to know if there is somebody else working on this. Any suggestions appreciated. Alcides. ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig
Re: [C++-sig] boost::python for Python 3.0
On Mon, Jun 1, 2009 at 7:41 PM, Alcides Viamontes Esquivel wrote: > Dear all: > > I would like to know if there is any progress on the development of a > version of boost::python for Python 3.0, the last activity that I can > track on this is back to the first days of April; that includes > mailing lists and the boost repository. > > I played a little with it and last night I succeeded in compiling > boost::python for Python 3.0 and in running the first test > (test_builtin_converters.py), but of course a lot have still to be > done (the const char* and char* issue, among many ones...). I would > like to know if there is somebody else working on this. > > Any suggestions appreciated. > > Alcides. > Hi Alcides, Yes I'm working on py3k support as my GSoC project. And as you see, the current situation is it can be compiled under Python 3, and have some tests passed. But now I get stuck on the Python unicode string and const char* conversion issue. In Python 2.x, the Python string -> const char* conversion can be simply done by a lvalue conversion. But in Python 3, the conversion path would be unicode -> (encoding to) bytes -> const char*. This requires an rvalue conversion. Bit after reading the code in extract.hpp, I found that since char* is a pointer, the conversion must be done as a lvalue conversion. This is a short description of the problem, please forgive me if it is not clear. :) So I'm still reading the code about call policies and type converting, hopefully I can state the problem clearer and even find out a solution when I get more understanding about BPL internal. Thanks for your interesting! :) -- Haoyu Bai ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig
Re: [C++-sig] boost::python for Python 3.0
Good to know that you are on it! I see your point with const char*, not to mention char* (there is a 'rewrap' in test_builtin_converters.py for that too). For PyUnicode objects, lvalue conversions are not an option. Short of that, the only remaining solution is to do an rvalue conversion by encoding and putting the result in a buffer which the user is responsible of releasing, as in this: scoped_array< char > my_chars = extract< const char* >(a_python_object); do something with it The shortcomings of this are: * The encoding to use is restricted to one without zeroes (e.g. utf-8) * It is easy to leak memory, because legacy code using boost::python might have been instructed in considering my_chars a pointer to an internal reference. And it shouldremain that way for Python 2.x. This point breaks the approach completely. However, as you pointed out, a solution can be worked using call policies. I will think on it a little more. Regards! On Mon, Jun 1, 2009 at 8:06 AM, Haoyu Bai wrote: > On Mon, Jun 1, 2009 at 7:41 PM, Alcides Viamontes Esquivel > wrote: >> Dear all: >> >> I would like to know if there is any progress on the development of a >> version of boost::python for Python 3.0, the last activity that I can >> track on this is back to the first days of April; that includes >> mailing lists and the boost repository. >> >> I played a little with it and last night I succeeded in compiling >> boost::python for Python 3.0 and in running the first test >> (test_builtin_converters.py), but of course a lot have still to be >> done (the const char* and char* issue, among many ones...). I would >> like to know if there is somebody else working on this. >> >> Any suggestions appreciated. >> >> Alcides. >> > > Hi Alcides, > > Yes I'm working on py3k support as my GSoC project. And as you see, > the current situation is it can be compiled under Python 3, and have > some tests passed. > > But now I get stuck on the Python unicode string and const char* > conversion issue. In Python 2.x, the Python string -> const char* > conversion can be simply done by a lvalue conversion. But in Python 3, > the conversion path would be unicode -> (encoding to) bytes -> const > char*. This requires an rvalue conversion. Bit after reading the code > in extract.hpp, I found that since char* is a pointer, the conversion > must be done as a lvalue conversion. This is a short description of > the problem, please forgive me if it is not clear. :) > > So I'm still reading the code about call policies and type converting, > hopefully I can state the problem clearer and even find out a solution > when I get more understanding about BPL internal. > > Thanks for your interesting! :) > > -- Haoyu Bai > ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig
[C++-sig] Advantages/Disadvantages
Hello, I was wondering what were the advantages and disadvantages of using Boost.Python or SWIG as opposed to just working with the built-in features that allow the embedding/wrapping of C++ code into PYTHON projects. Will using Boost.Python or SWIG make life easier while coding but result in a loss of performance at runtime and an increase in processing time? Thanks, Kevin ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig
Re: [C++-sig] boost::python for Python 3.0
On Jun 1, 2009, at 5:52 AM, Alcides Viamontes Esquivel wrote: Good to know that you are on it! Same here, I'm super excited about python 3 compatibility! I work on http://mapnik.org which uses boost python heavily. Cheers, Dane ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig