On Wed, Mar 14, 2007 at 12:29:09AM -0700, Talin wrote: > # The metaclass > class OrderedClass(type): > > # The custom dictionary > class member_table(dict): <snip>
I would move the member_table class out of the OrderedClass namespace so no one gets any funny ideas that it has to be nested. > Alternate Proposals > > Another good suggestion was to simply use an ordered dict for all > classes, and skip the whole 'custom dict' mechanism. This was based > on the observation that most use cases for a custom dict were for > the purposes of preserving order information. However, this idea has > two drawbacks, first because it means that an ordered dict > implementation would have to be added to the set of built-in types > in Python, and second because it would impose a slight speed (and > complexity) penalty on all class declarations. FYI, I did a hacky implementation to test speed by making a copy of dictobject.c and storing key names in a PyList on the object. The slowdown for inserting 100k unique keys (/usr/share/dict/words) was 10%. There was no appreciable slowdown for lookup (it uses the normal hash lookup). I didn't implement deletion so I don't know how much it would suffer. -Jack _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
