最高は効率的に stdin ハンドル上の数字のリストで n 個の上位 (または下位) の数字を検索するプログラムです。伝統的な方法はこれにコンピューティングの GNU を使用して並べ替え O (n log n) n がチェックする番号の数の実行時間を持っている必要があります。最高 O (n ログ m)、m は維持し数の実行時間が必要です。GNU 並べ替えを最高のパフォーマンスを比較するグラフを提供しています。
Additional performance gains have been achieved using a heap or treap, depending on command line options and available Python modules. The heap version performs well and uses modules that come with Python. The treap version performs even better, but requires an extra module.