Thanks for the review, Nick. I'll be uploading a new patch in a couple hours with your recommended fixes.
Regarding the comments on python-ideas, would it be better to use a weakref proxy around the function, to help with the reference cycles? That's what I was doing with my closure-based solution. I didn't do it here just to see what would happen and I didn't see any problems in my very limited testing (basically just 'make test'). I don't mind using weakrefs and, if it matters, I could pre-allocate the weakref proxy in PyFunction_New to save a little overhead at each call.
For the moment I left in the code to limit f_func to only functions. I'll respond to that on python-ideas.
Finally, how does this patch relate to the ABI? I'm not too familiar with it (read through PEP 384) and want to make sure I'm okay here. |