[Stackless] Draft for new wiki page: Boost.Python

Juho Mäkinen juho.makinen at gmail.com
Mon Apr 3 12:30:05 CEST 2006

Hello. I was about to add a new page to stackless.com/wiki about Boost.Python,
but I (site username: garo) don't have enough privileges to create new pages,
so I'll just post the page draft here.

Maybe it would be wise to allow new users to add new pages to the wiki
as default, so the community could easily create documentation about

--- draft starts here ---
Stackless python can be used with <a
just as normal python.
The only thing to do, is to compile Boost.Python against Stackless python.
This can be done with the boost build system (bjam), or by including
the Boost.Python sources into your project and compiling this along
your other project source files.

Stackless special PyObject types can be used using
boost::python::object and boost::python::handle, just as normal
PyObject. It is safe to static_cast<> or reinterpret_cast<> from
PyObject to, for example PyTaskletObject and PyChannelObject.

Example of creating a new channel object, storing it into
boost::python::object and using the channel which is stored as

        namespace py = boost::python;
        PyChannelObject* rawChannel = PyChannel_New(NULL);
        PyChannel_SetPreference(rawChannel, 0);

        py::object channel =

        // get channel balance
        int balance = py::extract<int>(channel.attr("balance"));

        // Get the PyChannelObject back from channel object
        rawChannel = reinterpret_cast<PyChannelObject*>(channel.ptr());
        PyChannel_Send(rawChannel, Py_None);

More info about Boost.Python can be found from these resources:
 - <a href="http://www.boost.org/libs/python/doc/index.html">http://www.boost.org/libs/python/doc/index.html</a>
 - <a href="http://www.boost.org/libs/python/doc/tutorial/doc/html/index.html">http://www.boost.org/libs/python/doc/tutorial/doc/html/index.html</a>
 - <a href="http://www.python.org/moin/boost_2epython">http://www.python.org/moin/boost_2epython</a>

--- draft ends here ---

 - Juho Mäkinen, http://www.juhonkoti.net

Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list