Extending C/C++ systems with Python is an attractive idea, but deciding on which way to extend it can be difficult. Here are two ideas which I have used with success.
Another example could be serializing data to a database using Python libraries such as SQLite3. But, we could extend our messaging server examples to provide outputs to SQL databases such as SQLite:
import sqlite3 sqlconn = None
Then, in the initialization, we could:
def pyinit_server (port): global roster, sqlconn sqlconn = sqlite3.connect ('sqlite.db')
Finally, in the callbacks:
cdef int pyconnect_callback (client *c, char * args): global sqlconn sqlconn.execute ("SQL....")
Now we can successfully output the data into an SQLite database ...