def getNewAVL(seq): if has_fast_tree_support(): from bintrees import FastAVLTree return FastAVLTree(seq) else: from bintrees import AVLTree return AVLTree(seq)
fp.write(repr(keys)) fp.close() print ("Nodes: %d" % len(keys)) t = Timer("rb_build()", setup_RBTree) print_result(t.timeit(COUNT), 'RBTree build only') t = Timer("crb_build()", setup_FastRBTree) print_result(t.timeit(COUNT), 'FastRBTree build only') t = Timer("rb_build_delete()", setup_RBTree) print_result(t.timeit(COUNT), 'RBTree build & delete') t = Timer("crb_build_delete()", setup_FastRBTree) print_result(t.timeit(COUNT), 'FastRBTree build & delete') # shuffle search keys shuffle(keys) t = Timer("rb_search()", setup_RBTree) print_result(t.timeit(COUNT), 'RBTree search') t = Timer("crb_search()", setup_FastRBTree) print_result(t.timeit(COUNT), 'FastRBTree search') if __name__ == '__main__': if not has_fast_tree_support(): print("Cython extension for FastRBTree is NOT working.") else: print("Cython extension for FastRBTree is working.") main()
def test_cython_support(self): if PYPY: self.assertFalse(has_fast_tree_support()) else: self.assertTrue(has_fast_tree_support())