對 Python 的 列表/字典/集合 進行排序:sorted_containers

jopen 10年前發布 | 29K 次閱讀 Python開發 sorted_containers

sorted_containers 對 Python 的 列表/字典/集合 進行排序. 支持 Python 2.6, 2.7(PyPY), 3.2(PyPy 3), 3.3 和 3.4。

>>> sl = sortedcontainers.SortedList(xrange(10000000))
>>> 1234567 in sl
True
>>> sl[7654321]
7654321
>>> sl.add(1234567)
>>> sl.count(1234567)
2
>>> sl *= 3
>>> len(sl)
30000003

特性

  • 純Python
  • 完整的文檔
  • Benchmark comparison (alternatives, runtimes, load-factors)
  • 100% test coverage
  • Hours of stress testing
  • Performance matters (often faster than C implementations)
  • Compatible API (nearly identical to popular blist and rbtree modules)
  • Feature-rich (e.g. get the five largest keys in a sorted dict: d.iloc[-5:])
  • Pragmatic design (e.g. SortedSet is a Python set with a SortedList index)
  • Developed on Python 2.7
  • Tested on CPython 2.6, 2.7, 3.2, 3.3, 3.4 and PyPy 2.2+, PyPy3 2.3.1+
  • </ul>

    項目主頁:http://www.baiduhome.net/lib/view/home/1414739114153

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!