Jeff Shannon <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >>Jeff Shannon <[EMAIL PROTECTED]> writes: >>>Additionally, as I understand it UserList and UserDict are implemented >>>entirely in Python, which means that there can be significant >>>performance differences as well. >> >>Actually, UserList and UserDict are just wrappers around the builtin >>types. So the performance hit is one Python function call - pretty >>much neglible. But new code should still subclass the builtins. > > Ah. I suppose that makes sense, now that the builtins are > subclassable. Originally, they had to be implemented in Python in > order to make them subclassable, but now the type/class unification > has changed all that...
Go take a look at UserList. It's a wrapper around the builtin list, not a descendant of the builtin list. Most of the methosd look like: def name(self, args): self.data.name(args) The exceptions tend to be tweaking the exact behavior based on the argument type(s). <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list