Tangram for Python?

Andrew M. Kuchling akuchlin at mems-exchange.org
Tue Mar 7 16:43:15 CET 2000

[adding crosspost to comp.lang.python, and redirecting follow-ups there]

Jean-Louis Leroy <jll at skynet.be> quoted:
> > Do you have a version of Tangram for Python?

Ah, I'd be interested in seeing a Python version of Tangram, too.
> There are several features that determine how well persistence can be
> implemented. Does the language support:
> 1) direct attribute access, like in Perl or Smalltalk (#instVarAt:)
>    [for orthogonality]

Do you mean simply the ability to refer to obj.attr, instead of going
through a get_attr() accessor function?  If that's correct, then yes,
Python has that.
> 2) interception of attribute access, à la Perl's tie()
>    [for orthogonal relationships-on-demand]

Yes; you can define a __getattr__(self, attrname) method for a class,
See http://www.python.org/doc/ref/attribute-access.html for the
> 3) weak references
>    [for object unicity without leakage]

Not in the core; there's an extension floating around for them, I
think.  (M-A Lemburg `'s mxProxy, IIRC?)

> 4) either deterministic object lifecycle (like in C++ and Perl) or
>    reachability detection
>    [for fresh unique objects]

That depends.  The C implementation of Python uses reference counting,
so objects are destroyed when they go out of scope, unless they get
trapped in a cycle, but JPython's behaviour is dependent on how the
underlying Java VM is implemented.

> 5) operator overloading
>    [for a 'natural' way of building where-clauses]

Yes; again, you can define magically-named methods such as __add__,
__sub__, __mul__, etc. to overload various operations.  (Though in all
honesty, from reading the Tangram docs I thought the use of
overloading to build where-clauses was a bit opaque and confusing.)

> Tangram has been written in Perl and C++. Perl has all but (4) and C++
> has all but (1) and (2). I'd be interested to learn about Python's
> amenability to orthogonal persistence. I'll elaborate on the 5
> features if asked to.

I think Python has all but (3); someone please correct me if I'm wrong.  
People have implemented persistence for Python before, most notably in the ZODB;
see http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html .

A.M. Kuchling			http://starship.python.net/crew/amk/
I claim complete innocence and ignorance! It must have been Tim. I wouldn't
know a Trondheim Hammer if it fell on my foot!
    -- Steve Majewski, 10 Jan 1995

More information about the Python-list mailing list