[Python-Dev] Berkeley DB

Jeremy Hylton jeremy@beopen.com
Tue, 25 Jul 2000 12:29:34 -0400 (EDT)

>>>>> "AMK" == Andrew Kuchling <akuchlin@mems-exchange.org> writes:

  AMK> On Tue, Jul 25, 2000 at 11:56:05AM -0400, Fred L. Drake,
  AMK> Jr. wrote:
  >> module.  The existing bsddb module *is* the public interface; if
  >> db_wrap is a direct replacment, it should be called bsddb instead
  >> of _bsddb.

  AMK> It's not; in fact, db_wrap.c is SWIG-generated code while the
  AMK> old bsddb module was a hand-written extension.  Is it OK to add
  AMK> a SWIG-generated module to the core?  (I have an irrational
  AMK> dislike SWIG's trick of encoding pointers as strings, because
  AMK> it provides a way to deliberately engineer core dumps; it's
  AMK> just sort of unsettling.)

Indeed!  The stock SWIG produces dangerous code for pointers and
inefficient code for returning multiple values.  The code it produces
is hard to read at least in part because it is indented incorrectly.
I don't think any of these features are acceptable for a core module.

I have some patches and typemaps for SWIG that do a better job, but
it's still not great.  If people are interested, I can post to the
list.  The two primary changes are to use PyCObjects for pointers and
to generate better code for returning tuples.  (The current code
generates a return tuple incrementally; for each value, it creates a
new tuple and appends it to the old return value.)


PS Andrew: The patched version of SWIG might still be installed in the
depot at CNRI.  You could try it out.