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

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
主站蜘蛛池模板: 松阳县| 多伦县| 七台河市| 衡东县| 内丘县| 宜兰市| 东海县| 怀仁县| 德钦县| 望城县| 和田市| 周宁县| 甘洛县| 金乡县| 额济纳旗| 抚顺县| 永川市| 根河市| 泸西县| 东丽区| 宜丰县| 岳阳市| 剑阁县| 汕尾市| 三穗县| 龙川县| 汉寿县| 临澧县| 天津市| 石门县| 垫江县| 南安市| 柳林县| 黑水县| 讷河市| 天气| 简阳市| 武乡县| 合川市| 汕头市| 乌兰察布市|