On Nov 30, 2008, at 4:33 AM, Dag Sverre Seljebotn wrote:

> Here's an idea:
>
> Have a babysit mode for refcounting.
>
> a) When entering an exiting from a function, "__Pyx_PushRefCountFrame"
> and "__Pyx_PopRefcountFrame(__pyx_r)" are called.
>
> b) Use __Pyx_INCREF and __Pyx_DECREF instead
>
> c) Whenever a function call returns an object with a reference,
> __Pyx_GOTREF should be called on the returned object.
>
> (Point c) could be done with refactoring "the call of a Python C API
> function" to code.call_func or similar -- I'm noticing that a lot of
> code is duplicated all over the place currently.)
>
> With these, I think it should be possible to (conditionally on a
> #define) define things in such a way that a) __Pyx_DECREF can log  
> useful
> information and exit more gracefully than a segfault, b)
> __Pyx_PopRefcountFrame can report any memory leaks, locally from the
> perspective of the function.
>
> Am I overlooking anything obvious? What do you think? I'm merely
> wondering if it is a good enough idea to warrant creating a ticket for
> it, not volunteering at this stage.
>
> If this was done before moving more temps it could perhaps help with
> gaining confidence in a change quickly, and it would be a useful
> addition to the regression test framework for the future as well.


This is to ease development, not for end-users, right? I think this  
could be a good idea, though it's unclear exactly what  
"__Pyx_PushRefCountFrame" and "__Pyx_PopRefcountFrame" would do. And  
would __Pyx_DECREF be more useful than running under gdb?

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to