C++ version of the C Python API?

Stargaming stargaming at gmail.com
Sat Oct 20 01:40:10 EDT 2007


On Fri, 19 Oct 2007 17:37:29 -0500, Robert Dailey wrote:

> Hi,
> 
> Is there a C++ version of the C Python API packaged with python 2.5? It
> would be nice to have a OOP approach to embedding python in C++. It
> would also be a bonus if this C++ Python API cleaned up a lot of the
> messy code involved in embedding python.
> 
> Thanks.

Perhaps, the remark about `C++ extensions`_ or `Embedding in C++`_ in the 
`Extending and Embedding`_ docs (described on doc.python.org as a 
"tutorial for C/C++ programmers") can help.

Depending on your level of embedding, those random annotations spread 
over the extending docs, found with a little patience and ctrl+f, might 
help:

  * "In C++, the operators new and delete are used with essentially the 
same meaning and we'll restrict the following discussion to the C case." 
-- `1.10 Reference counts <http://docs.python.org/ext/refcounts.html>`_
  * "Note that PyMODINIT_FUNC declares the function as void return type, 
declares any special linkage declarations required by the platform, and 
for C++ declares the function as extern "C"." -- `1.4 The Module's Method 
Table and Initialization Function <http://docs.python.org/ext/
methodTable.html>`_

Cheers,
Stargaming

.. _C++ extensions: http://docs.python.org/ext/cplusplus.html
.. _Embedding in C++: http://docs.python.org/ext/embeddingInCplusplus.html
.. _Extending and embedding: http://docs.python.org/ext/ext.html



More information about the Python-list mailing list