nodes: 0, module; 1, function_definition; 2, function_name:optimize; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, comment:# load benchmarks results; 8, with_statement; 9, comment:# optimize; 10, for_statement; 11, comment:"""Sort algorithm implementations by speed.
          """; 12, with_clause; 13, block; 14, pattern_list; 15, call; 16, block; 17, with_item; 18, expression_statement; 19, identifier:alg; 20, identifier:libs_names; 21, attribute; 22, argument_list; 23, expression_statement; 24, if_statement; 25, comment:# drop slow libs; 26, expression_statement; 27, comment:# sort libs by speed; 28, expression_statement; 29, as_pattern; 30, assignment; 31, identifier:libs_data; 32, identifier:items; 33, assignment; 34, not_operator; 35, block; 36, assignment; 37, call; 38, call; 39, as_pattern_target; 40, identifier:libs_data; 41, call; 42, identifier:libs; 43, call; 44, identifier:libs; 45, continue_statement; 46, subscript; 47, list_comprehension; 48, attribute; 49, argument_list; 50, identifier:open; 51, argument_list; 52, identifier:f; 53, attribute; 54, argument_list; 55, attribute; 56, argument_list; 57, attribute; 58, identifier:alg; 59, identifier:lib; 60, for_in_clause; 61, if_clause; 62, subscript; 63, identifier:sort; 64, keyword_argument; 65, identifier:LIBRARIES_FILE; 66, string; 67, identifier:json; 68, identifier:load; 69, identifier:f; 70, identifier:self; 71, identifier:get_libs; 72, identifier:alg; 73, identifier:self; 74, identifier:libs; 75, identifier:lib; 76, identifier:libs; 77, comparison_operator:[lib.module_name, lib.func_name] in libs_names; 78, attribute; 79, identifier:alg; 80, identifier:key; 81, lambda; 82, string_content:r; 83, list; 84, identifier:libs_names; 85, identifier:self; 86, identifier:libs; 87, lambda_parameters; 88, call; 89, attribute; 90, attribute; 91, identifier:lib; 92, attribute; 93, argument_list; 94, identifier:lib; 95, identifier:module_name; 96, identifier:lib; 97, identifier:func_name; 98, identifier:libs_names; 99, identifier:index; 100, list; 101, attribute; 102, attribute; 103, identifier:lib; 104, identifier:module_name; 105, identifier:lib; 106, identifier:func_name
code: def optimize(self):
          """Sort algorithm implementations by speed.
          """
          # load benchmarks results
          with open(LIBRARIES_FILE, 'r') as f:
              libs_data = json.load(f)
          # optimize
          for alg, libs_names in libs_data.items():
              libs = self.get_libs(alg)
              if not libs:
                  continue
              # drop slow libs
              self.libs[alg] = [lib for lib in libs if [lib.module_name, lib.func_name] in libs_names]
              # sort libs by speed
              self.libs[alg].sort(key=lambda lib: libs_names.index([lib.module_name, lib.func_name]))