diff options
Diffstat (limited to 'Lib/heapq.py')
-rw-r--r-- | Lib/heapq.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/Lib/heapq.py b/Lib/heapq.py index b20f04d..8fb3d09 100644 --- a/Lib/heapq.py +++ b/Lib/heapq.py @@ -311,16 +311,6 @@ def _siftup_max(heap, pos): heap[pos] = newitem _siftdown_max(heap, startpos, pos) -# If available, use C implementation -try: - from _heapq import * -except ImportError: - pass -try: - from _heapq import _heapreplace_max -except ImportError: - pass - def merge(*iterables, key=None, reverse=False): '''Merge multiple sorted inputs into a single sorted output. @@ -592,6 +582,24 @@ def nlargest(n, iterable, key=None): result.sort(reverse=True) return [r[2] for r in result] +# If available, use C implementation +try: + from _heapq import * +except ImportError: + pass +try: + from _heapq import _heapreplace_max +except ImportError: + pass +try: + from _heapq import _heapify_max +except ImportError: + pass +try: + from _heapq import _heappop_max +except ImportError: + pass + if __name__ == "__main__": |