I'd like to propose further enhancements:
- use intermingled declarations in the affected functions; this will make GIL acquisition stand more out, and it also improves readability and makes it easier to trace refs
- take the naming step further: I'd like to normalise PyObject * callback variable names, the extremely long function_pinboard_* names, and also drop the C callback prefixes ('_' and 'pysqlite_')
If you agree, I'll create separate PR's for those; one for each refactor. I think it will enhance readability a lot.