4 ms·
> The canonical Python example of this is defining a tree data structure: def tree(): return defaultdict(tree) But you're not defining a data structure -- y
by dons 14y ago
> The canonical Python example of this is defining a tree data structure:
def tree(): return defaultdict(tree)
But you're not defining a data structure -- you're just reusing the builtin dictionary type.
Try defining say a RB tree without using builtin container types, and you quickly see how poor these languages' support for new data structures is.
- sanderjd 14y agoI think you're willfully missing the point - you don't have to implement an rb tree without the built in containers because the language comes with built in containers. Python doesn't need to be optimized for doing such things from scratch because hardly anybody ever needs to do such things from scratch.
- Chris_Newton 14y agoThe language comes with a small number of simple but widely applicable containers. That doesn’t negate dons’ point that if you need something other than those containers there is relatively poor support for defining your own.
- ComputerGuru 14y agoI don't get your point. In C++ "return std::set<int>" - there's your tree.