There are some APIs that make it clearer what the code intentions are, and also make it shorter. pyutil will need to provide definitions for earlier python versions.
[x] Look for memsets and use PyMem_Calloc where possible instead
[x] PyObject_IsTrue in most places can be replaced with simpler code that does PyLong /PyBool check. It means empty strings won't be considered bools so we get better type checking.
This needs something more formal:
[x] Py_TYPE(self)->tp_free((PyObject *)self);
[x] PY_EXC_HANDLE wherever exceptions are fetch then restored
[x] Make PyTypeObject use C99 style initialization (.tp_flags = ...)
There are some APIs that make it clearer what the code intentions are, and also make it shorter. pyutil will need to provide definitions for earlier python versions.
[x] Look for memsets and use PyMem_Calloc where possible instead
[x] Py_NewRef replaces an incref and assignment
[x] Py_Is/IsNone/Istrue/IsFalse avoids direct equality tests
[x] PyObject_IsTrue in most places can be replaced with simpler code that does PyLong /PyBool check. It means empty strings won't be considered bools so we get better type checking.
This needs something more formal:
[x] Py_TYPE(self)->tp_free((PyObject *)self);
[x] PY_EXC_HANDLE wherever exceptions are fetch then restored
[x] Make PyTypeObject use C99 style initialization (
.tp_flags = ...
)[x] Py_TypeName instead of
Py_TYPE(o) -> tp_name