I finally traced #91 back to a missing Py_DECREF after PySequence_SetItem. Unlike, for example, PyList_SET_ITEM, this function is not reference stealing.
I've added some comments that attempt to clarify the difference between the way this code handles reference stealing and non-reference stealing calls.
Coming along for the ride in this fix is a swap from Py_BuildValue to PyLong_FromLong, which avoids the need for a format string and should- in theory- be faster. This isn't entirely unrelated, since it aims to balance the cost of calling Py_DECREF for every byte, but I have no substantive evidence to back this up.
I finally traced #91 back to a missing
Py_DECREF
afterPySequence_SetItem
. Unlike, for example,PyList_SET_ITEM
, this function is not reference stealing.I've added some comments that attempt to clarify the difference between the way this code handles reference stealing and non-reference stealing calls.
Coming along for the ride in this fix is a swap from
Py_BuildValue
toPyLong_FromLong
, which avoids the need for a format string and should- in theory- be faster. This isn't entirely unrelated, since it aims to balance the cost of callingPy_DECREF
for every byte, but I have no substantive evidence to back this up.