You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python][C++] Simplify/Validate PyObject refcount in udf.cc #36000
Describe the bug, including details regarding any error messages, version, and platform.
In udf.cc, there is interaction between C++ and Python where the C++ code holds a user defined Python object inside a Kernel and invoke it over input data.
Due to this interaction, there are a number of Py_INCREF call as well as using OwnRef to manage the refcount for the PyObject (which represents the user defined function. The current code for managing it is either over complicated and/or bug where the C++ code might be over increasing the refcount. While this is not a huge issue (it probably cause the Python function to never be garbage collected), it could use some clean up / documentation as least to improve maintainability.
I used an AI agent to check this against current releases, and I've reviewed the results.
🤖 :
This looks to have been fixed by #43557 (released in 18.0.0), which removed the extra Py_INCREF calls in udf.cc and added comments on the ones that remain.
Registering a scalar UDF and calling it 111 times, the reference count of the Python function behaves like this:
pyarrow
After registering
After 1, +10, +100 calls
17.0.0
5
6, 16, 116
26.0.1
3
3, 3, 3
So the count no longer grows with each call. Closing as fixed.
Activity
thisisnic commentedon Nov 25, 2026
I used an AI agent to check this against current releases, and I've reviewed the results.
🤖 :
This looks to have been fixed by #43557 (released in 18.0.0), which removed the extra
Py_INCREFcalls inudf.ccand added comments on the ones that remain.Registering a scalar UDF and calling it 111 times, the reference count of the Python function behaves like this:
So the count no longer grows with each call. Closing as fixed.