Prothon Prototypes vs Python Classes
joe at notcharles.ca
Sun Mar 28 18:40:03 CEST 2004
In article <mailman.11.1080489481.20120.python-list at python.org>, Jeff Epler wrote:
> def __call__(
> __metaclass__ = PrototypeMeta
> class Thing:
You're missing most of call() there.
BTW, I've got three pure-python solutions now (four when this one's
fixed) but it turns out they all suffer from a flaw:
>>> class TestProto: l = 
>>> class Test2(TestProto): pass
We really need copy-on-write lists and dicts - and large objects in
general - for this to work.
A bunch of the solutions already check for method definitions and
convert them to instances of a type ProtoMethod. We could do the same
with COWDict and COWSequence classes in __setattr__, or something like
that. That takes care of 80% of the problem. If we can make it work
for subclasses as well, it works for 90%. For the remaining 10% (large
datastructures unrelated to dicts/sequences) it might be enough just to
let the user handle it.
(BTW, I plan to write up all the various solutions I've seen - including
a link to Prothon - in the next few days, if I have time after work.
Next weekend at the latest.)
More information about the Python-list