repr(?) is very slow
Status: Inactive
Brought to you by:
dasnarian
import avl
t = avl.new()
for i in range(2**16):
t.insert(i)
t
list(t)
I think the problem is the infamous O(n^2) array concat problem with strings. The repr function works by concating each item's repr onto a string.
I don't have a patch, but there are two obvious solutions: a) convert to a list and return repr for that b) construct the string in bottom up order from the tree - concat reprs from neighbouring branches into a single string and move up the tree:
repr(node):
return repr(node.left) + "," + repr(node.right)