def merge_sims(oldsims, newsims, clip=None):
if oldsims is None:<EOL><INDENT>result = newsims or []<EOL><DEDENT>elif newsims is None:<EOL><INDENT>result = oldsims<EOL><DEDENT>else:<EOL><INDENT>result = sorted(oldsims + newsims, key=lambda item: -item[<NUM_LIT:1>])<EOL><DEDENT>if clip is not None:<EOL><INDENT>result = result[:clip]<EOL><DEDENT>return result<EOL>
Merge two precomputed similarity lists, truncating the result to `clip` most similar items.