[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PROPOSAL] Safe Memory Management for the Python/SWIG bindings

From: Mark Benedetto King <mbk_at_lowlatency.com>
Date: 2005-07-23 02:45:09 CEST

On Wed, Jul 20, 2005 at 04:23:40PM -0400, David James wrote:
> On 7/19/05, David James <james82@gmail.com> wrote:
> >
> > In order for the above implementation to work, we will need to have a
> > Python proxy object for every C object that is accessible from Python.
> > Currently, SWIG only creates Python proxy objects if we provide it
> > with the details of the internals of the C struct.
> >
> > Currently, we do not provide SWIG with all the details of how the
> > internals of Subversion are implemented, so SWIG treats some
> > Subversion datastructures as opaque pointers.
> OK, I've identified the problem. So far, so good.
> > We can fix this problem by using the %include directive -- just
> > %include the internal .h or .c files which describe the structure.
> > If we do this, then SWIG will generate real Python objects for
> > our "opaque pointers" -- not just C Objects.
> I've looked into this issue further. There is an easier way to ask
> SWIG to setup proxy objects: just setup a dummy declaration, and tell
> SWIG which functions to call in order to create and destroy objects.
> Kouhei has demonstrated this technique inside core.i:
> /* Dummy declaration */
> struct apr_pool_t
> {
> };
> /* Leave memory administration to ruby's GC */
> %extend apr_pool_t
> {
> apr_pool_t(apr_pool_t *parent=NULL, apr_allocator_t *allocator=NULL) {
> /* Disable parent pool. */
> return svn_pool_create_ex(NULL, NULL);
> }
> ~apr_pool_t() {
> apr_pool_destroy(self);
> }
> };
> In order for my proposal to work, we will need to use Kouhei's
> technique to create Pythonic proxies for all of the SVN datatypes. If
> we define a single proxy for each object inside the SWIG interface
> file, SWIG will generate code in all three languages (Python, Perl,
> Ruby) automatically.

I know nothing of SWIG, but am a little concerned by this sort
of GC interaction. What happens when a pool goes out-of-scope
from Python's point of view, but references to it remain in
datastructures in other pools?

Phrased differently, how does python know whether the pool is
still reachable?


To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Jul 25 01:48:42 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.