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

  • Mastering Python
  • Rick van Hattem
  • 159字
  • 2021-07-16 11:10:33

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
主站蜘蛛池模板: 淮北市| 汉源县| 新平| 辽源市| 东丽区| 南宫市| 开原市| 宽甸| 新丰县| 三台县| 章丘市| 壶关县| 延川县| 新余市| 沭阳县| 吴忠市| 吉木乃县| 临湘市| 托克逊县| 万年县| 从江县| 沁水县| 静安区| 京山县| 浦江县| 泸水县| 东乡族自治县| 都兰县| 海门市| 永定县| 东平县| 麻阳| 介休市| 伊宁市| 犍为县| 钦州市| 定南县| 石城县| 上虞市| 佳木斯市| 鲜城|