Few more notes on the code: You may use the @property in such situations (or you may just use attributes, dropping the property). Note that Python doesn't inline functions calls like Java HotSpot does quite often. def __children(self): raise NotImplementedError() children = property(__children) ==> (not tested!) @property def __children(self): raise NotImplementedError()
If the profiling shows this is s slow, and it's used on lot of items, there are faster O(1) algorithms for this, like this one: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/466330 @staticmethod def determine_median(numbers): return sorted(numbers)[ len(numbers) / 2 ] I have seen you use lot of double underscores (I think one may often suffice, but usually two aren't a problem): def __children(self): Stripped of comments, docstrings, and empty lines the code is just 280 lines long (it's 1498 with them!), so a translation doesn't seem too much work (expecially if the original version was Java). The code seem really well commented, organized, etc. And I like it, it looks better than 90+% of the commercial Python code I see :-) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list