[pybsddb] About bsddb objects subclassing

Gregory P. Smith greg at krypto.org
Wed Oct 1 22:42:17 CEST 2008


Mostly because nobody ever implemented it.  Thats what the dbobj
wrapper module was for.

Regardless, consider whether you think subclassing to be a good idea
or not.  If a database is subclassed and someone overrides the get
method, should all internal operations done in the C module now call
back up through that get method?  Why bother subclassing if there are
no virtual methods?

I personally dislike APIs that allow themselves to be directly
subclassed.  Merely making your own class that contains a DB or what
not and provides duck typed methods where needed to behave the same
makes more sense and is safer and less surprising in its behavior than
an actual subclass given that the C API has no virtual methods to
override and alter behavior with in a subclass.

just my two cents,
-gps

On Wed, Oct 1, 2008 at 9:21 AM, Jesus Cea <jcea at jcea.es> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Greg, is there any reason bsddb objects (DBEnv, DB, DBCursor, DBSequence
> and DBLock) are not subclassable?
>
> I'm planning to allow subclassing for 4.7.4. I would like to know if I'm
> going to hit an unforseen wall.
>
> Thanks for your time.
>
> - --
> Jesus Cea Avion                         _/_/      _/_/_/        _/_/_/
> jcea at jcea.es - http://www.jcea.es/     _/_/    _/_/  _/_/    _/_/  _/_/
> jabber / xmpp:jcea at jabber.org         _/_/    _/_/          _/_/_/_/_/
> .                              _/_/  _/_/    _/_/          _/_/  _/_/
> "Things are not so easy"      _/_/  _/_/    _/_/  _/_/    _/_/  _/_/
> "My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/
> "El amor es poner tu felicidad en la felicidad de otro" - Leibniz
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.8 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iQCVAwUBSOOjhplgi5GaxT1NAQLtqwP9GLD7uOX/JMJ3wwU93TjaZiAinbK/giLr
> GKT87ffdWPu7BrKXyqjXKmvakGFIyrvaUxdTTHn6dpSa3XCMpw/3dcNlK8Dp0HLm
> q/bvdYeVIulzaHZwiIgVeZlkyaZRRDsm6wfRkteRYy74aM9O299YGD/J0/A5jqnr
> MSPmDDaaFB4=
> =+wXg
> -----END PGP SIGNATURE-----
>



More information about the pybsddb mailing list