try: from _heapq import * except ImportError: pass
# When n>=size, it's faster to use sorted() try: size = len(iterable) except (TypeError, AttributeError): pass else: if n >= size: return sorted(iterable, key=key)[:n]
for order, it in enumerate(map(iter, iterables)): try: next = it.__next__ value = next() h_append([key(value), order * direction, value, next]) except StopIteration: pass _heapify(h)
来自 heapq.py
标签:...,except,value,next,try,pass From: https://www.cnblogs.com/sangern/p/17498357.html