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

Pure Python Optimizations

As mentioned in the last chapter, one of the most effective ways of improving the performance of applications is through the use of better algorithms and data structures. The Python standard library provides a large variety of ready-to-use algorithms and data structures that can be directly incorporated in your applications. With the tools learned from this chapter, you will be able to use the right algorithm for the task and achieve massive speed gains.

Even though many algorithms have been around for quite a while, they are especially relevant in today's world as we continuously produce, consume, and analyze ever increasing amounts of data. Buying a larger server or microoptimizing can work for some time, but achieving better scaling through algorithmic improvement can solve the problem once and for all.

In this chapter, we will understand how to achieve better scaling using standard algorithms and data structures. More advanced use cases will also be covered by taking advantage of third-party libraries. We will also learn about tools to implement caching, a technique used to achieve faster response times by sacrificing some space on memory or on disk.

The list of topics to be covered in this chapter is as follows:

  • Introduction to computational complexity
  • Lists and deques
  • Dictionaries
  • How to build an inverted index using a dictionary
  • Sets
  • Heaps and priority queues
  • Implementing autocompletion using tries
  • Introduction to caching
  • In-memory caching with the functools.lru_cache decorator
  • On-disk cache with joblib.Memory
  • Fast and memory-efficient loops with comprehensions and generators
主站蜘蛛池模板: 宁国市| 苏州市| 亚东县| 龙胜| 柯坪县| 大足县| 宁安市| 黄浦区| 江阴市| 五华县| 四会市| 滨州市| 阿克| 丹棱县| 边坝县| 新邵县| 松桃| 略阳县| 扎兰屯市| 南昌市| 永吉县| 涿鹿县| 子长县| 东宁县| 石景山区| 新源县| 南乐县| 老河口市| 长沙县| 临潭县| 宁远县| 寿宁县| 遵义县| 台安县| 宁强县| 文登市| 简阳市| 佛坪县| 阿鲁科尔沁旗| 延寿县| 岢岚县|