All Questions

0
votes
1answer
41 views

Python C-extension submodule Error: no module named “x”

I'm having difficulty with making a C-extension as a submodule in my code. The C extension below compiles just fine. The problem occurs when I attempt to add it to another module. Here's the C code: ...
0
votes
1answer
102 views

Struct variables overlap (Python C API)

Here's a strange one for you: I have been following the framework of this tutorial, in an attempt to write a Python module that will return a struct containing the results of a C function. The C ...
1
vote
1answer
461 views

python c api not able to import any module into the newly created module

Here is the code : python_script[] = "try:\n\timport sys\nexcept:\n\tprint\"cannot import sys\""; pNewMod = PyModule_New("mymod"); Py_Initialize(); pGlobal = PyDict_New(); pLocal = PyModule_GetDict(...
1
vote
1answer
413 views

Purpose and usage of PyModule_New

At face value, the C-API function PyModule_New and PyModule_NewObject obviously creates a new module object. The official Python Documentation provides the following explanation for ...
1
vote
1answer
946 views

Memory Leaks and Reference Counting in Python/C API

I am pretty new to Python and its C API. I still do not understand how reference counting works. I have written a module for particle tracking that exposes to python a number of C++ thread tracking ...
2
votes
1answer
571 views

Dynamically loading a python module from a DLL with Boost.Python

I have a DLL written in C++ that uses Boost.Python to run Python code. The Python code should be able to interact with the actual application (in the DLL). Is it possible to have both in one library ...
2
votes
2answers
934 views

Python / C-Api: Add class to module

Im currently trying to embed the python interpreter into my application. Because my application uses the Poco API for logging, I want to make it accessable through the logging module in python too. ...
1
vote
1answer
107 views

Python C module function argument reference counting

When I have a PyObject * obtained from PyArg_ParseTuple, do I need to make sure to Py_DECREF it before I return from the function? Example: static PyObject * modulefunc(PyObject * self, PyObject * ...
1
vote
2answers
2k views

embedding python module error

So i have a c to python wrapper that takes input strings and pass them to a python function. the error im getting is that the python API is not recognizing my python file... PyObject *pName, *pModule,...
3
votes
1answer
1k views

Define a global in a Python module from a C API

I am developing a module for Python using a C API. How can I create a variable that is seen as global from Python? For example, if my module is module, I want to create a variable g that does this ...