官术网_书友最值得收藏!

Chapter 3. Containers and Collections – Storing Data the Right Way

Python comes bundled with several very useful collections, a few of which are basic Python collection data types. The rest are advanced combinations of these types. In this chapter, we will explain some of these collections, how to use them, and the pros and cons of each of them.

Before we can properly discuss data structures and the related performance, a basic understanding of time complexity (and specifically the big O notation) is required. No need to worry! The concept is really simple, but without it, we cannot easily explain the performance characteristics of operations.

Once the big O notation is clear, we will discuss the basic data structures:

  • list
  • dict
  • set
  • tuple

Building on the basic data structures, we will continue with more advanced collections, such as the following:

  • Dictionary-like types:
    • ChainMap
    • Counter
    • Defaultdict
    • OrderedDict
  • List types:
    • Deque
    • Heapq
  • Tuple types:
    • NamedTuple
  • Other types:
    • Enum
主站蜘蛛池模板: 开阳县| 涞源县| 镇宁| 历史| 横峰县| 刚察县| 高青县| 陇川县| 扎兰屯市| 图木舒克市| 宝兴县| 镇宁| 新河县| 白城市| 新建县| 宜宾县| 修文县| 潮安县| 哈密市| 天水市| 泾源县| 尼木县| 西平县| 利辛县| 苏尼特右旗| 鹤岗市| 庆安县| 孝义市| 神池县| 策勒县| 商丘市| 二连浩特市| 留坝县| 黄陵县| 大余县| 连南| 永胜县| 内黄县| 康保县| 彭州市| 司法|