跳转至

2.5. Python数据结构的性能

2.5. Performance of Python Data Structures

现在你已经对大 O 符号及不同函数之间的差异有了一个大致的了解,我们在本节的目标是向你介绍 Python 列表和字典操作的 Big O 性能。接下来,我们会展示一些时间实验,说明在不同数据结构上使用某些操作的成本和收益。理解这些 Python 数据结构的效率对你来说非常重要,因为它们是我们在本书中实现其他数据结构时的构建基础。在本节中,我们不会解释为什么会有这样的性能表现。在后续章节中,你会看到列表和字典的某些可能的实现方式,以及性能如何依赖于这些实现。

Now that you have a general idea of Big O notation and the differences between the different functions, our goal in this section is to tell you about the Big O performance for the operations on Python lists and dictionaries. We will then show you some timing experiments that illustrate the costs and benefits of using certain operations on each data structure. It is important for you to understand the efficiency of these Python data structures because they are the building blocks we will use as we implement other data structures in the remainder of the book. In this section we are not going to explain why the performance is what it is. In later chapters you will see some possible implementations of both lists and dictionaries and how the performance depends on the implementation.


最后更新: 2024年9月12日
创建日期: 2024年9月9日