SitemapMcMillan Enterprises, Inc.
Distributing Python Programs
A Python C++ API
Sponsoring ME Inc.
About ME Inc.
SCXX - A Simple Python/C++ API
[Jan 25 2002]
Classes (PWEngine, FreeThreadedBlock, PythonThreadedBlock) for dealing with Python threas. PWOModule, a simple wrapper for Python module objects.
SCXX (Simplified CXX) is a lightweight C++ wrapper for dealing with PyObjects. It is inspired by Paul Dubois' CXX, but is much simpler. It does not use templates, so almost any compiler should work. It does not try to hide things like the Python method tables, or the init function. It only covers wrapping the most common PyObjects, with a minimum of code bloat. You can write extensions in C++ that can be loaded by a Python compiled and linked with the C compiler.
It lets you write C++ that looks a lot more like Python than the C API. Reference counts are handled automatically. It has not been optimized - it generally uses the highest possible level of the Python C API.
Most of the SCXX classes can be used to create new Python objects, or wrap existing ones. Wrapping an existing one forces a typecheck (except for PWOBase, which doesn't care). So:
Operators are overloaded so C++ looks as much like Python as possible.
Since errors are normally reported through exceptions, use code like this:
To signal errors in your own code, use:
To return a PWOxxx wrapped (or created) instance to Python, use disOwn():
Note that the PWOxxx classes are generally designed to be created on the stack. The corresponding PyObject is on the heap. When the PWOxxx instance goes out of scope, the PyObject is automatically decreffed (unless you've used disOwn()).
See SCXX API for more.
Download scxx_b3.tar.gz. Point to the installation directory with a
Warning: With certain recent versions of g++, you cannot
This code is licensed under the MIT license. Please see license.txt.
Report bugs (or feature requests) here. Please make sure you set Product to
McMillan Enterprises, Inc.