will often prove better choice in the end make no mistakesometimes you really do need objects that add functionality to builtin types or do something more custom the set classes we metfor instancecan add custom tools not directly supported by python todaybinary search trees may support some algorithms better than dictionaries and sets canand the tuple-tree stack implementation was actually faster than one based on built-in lists for common usage patterns moreovergraphs and permutations are something you must code on your own as we've also seenclass encapsulations make it possible to change and extend object internals without impacting the rest of your system although subclassing built-in types can address much of the same goalsthe end result is still custom data structure yet because python comes with set of built-inflexibleand optimized datatypesdata structure implementations are often not as important in python as they are in lesserequipped and lower-level programming languages before you code that new datatypebe sure to ask yourself whether built-in type or call might be more in line with the python way of thinking for more on extended data structures for use in pythonsee also the relatively new collections module in its standard library as mentioned in the preceding this module implements named tuplesordered dictionariesand more it' described in python' library manualbut its source codelike much in the standard librarycan serve as source of supplemental examples as well pytreea generic tree object viewer this has been command line-oriented to wrap upi want to refer you to program that merges the gui technology we studied earlier in the book with some of the data structure ideas we've explored here this program is called pytree-- generic tree data structure viewer written in python with the tkinter gui library pytree sketches out the nodes of tree on-screen as boxes connected by arrows it also knows how to route mouse clicks on drawn tree nodes back to the treeto trigger tree-specific actions because pytree lets you visualize the structure of the tree generated by set of parametersit' an arguably fun way to explore tree-based algorithms pytree supports arbitrary tree types by "wrappingreal trees in interface objects the interface objects implement standard protocol by communicating with the underlying tree object for the purposes of this pytree is instrumented to display binary search treesfor the next it' also set up to render expression parse trees new trees can be viewed by coding wrapper classes to interface to new tree types data structures