Skip to content.

logo Stackless Python

Personal tools


last edited 8 years ago by garo

Stackless python can be used with Boost.Python, 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 boost::python::object.

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

        py::object channel = py::object(py::handle<>(reinterpret_cast(rawChannel)));

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

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

More info about Boost.Python can be found from these resources:



Powered by Plone