Mastering Python High Performance

Fernando Doglio

商品描述

Measure, optimize, and improve the performance of your Python code with this easy-to-follow guide

About This Book

  • Master the do's and don'ts of Python performance programming
  • Learn how to use exiting new tools that will help you improve your scripts
  • A step-by-step, conceptual guide to teach you how to optimize and fine-tune your critical pieces of code

Who This Book Is For

If you're a Python developer looking to improve the speed of your scripts or simply wanting to take your skills to the next level, then this book is perfect for you.

What You Will Learn

  • Master code optimization step-by-step and learn how to use different tools
  • Understand what a profiler is and how to read its output
  • Interpret visual output from profiling tools and improve the performance of your script
  • Use Cython to create fast applications using Python and C
  • Take advantage of PyPy to improve performance of Python code
  • Optimize number-crunching code with NumPy, Numba, Parakeet, and Pandas

In Detail

Simply knowing how to code is not enough; on mission-critical pieces of code, every bit of memory and every CPU cycle counts, and knowing how to squish every bit of processing power out of your code is a crucial and sought-after skill. Nowadays, Python is used for many scientific projects, and sometimes the calculations done in those projects require some serious fine-tuning. Profilers are tools designed to help you measure the performance of your code and help you during the optimization process, so knowing how to use them and read their output is very handy.

This book starts from the basics and progressively moves on to more advanced topics. You'll learn everything from profiling all the way up to writing a real-life application and applying a full set of tools designed to improve it in different ways. In the middle, you'll stop to learn about the major profilers used in Python and about some graphic tools to help you make sense of their output. You'll then move from generic optimization techniques onto Python-specific ones, going over the main constructs of the language that will help you improve your speed without much of a change. Finally, the book covers some number-crunching-specific libraries and how to use them properly to get the best speed out of them.

After reading this book, you will know how to take any Python code, profile it, find out where the bottlenecks are, and apply different techniques to remove them.

Style and approach

This easy-to-follow, practical guide will help you enhance your optimization skills by improving real-world code.

商品描述(中文翻譯)

使用這本易於理解的指南,您可以測量、優化和改進您的Python代碼的性能。

關於本書:
- 掌握Python性能編程的要訣
- 學習如何使用新的工具來改進您的腳本
- 逐步概念性指南,教您如何優化和微調關鍵代碼片段

本書適合對Python開發有興趣的開發人員,無論是想提高腳本速度還是想提升技能水平。

您將學到:
- 逐步掌握代碼優化,並學習如何使用不同的工具
- 理解分析器是什麼,以及如何閱讀其輸出
- 解讀分析工具的視覺輸出,並改善腳本性能
- 使用Cython創建使用Python和C的快速應用程序
- 利用PyPy提高Python代碼的性能
- 使用NumPy、Numba、Parakeet和Pandas優化數據計算代碼

本書從基礎知識開始,逐漸深入更高級的主題。您將從分析開始,一直到撰寫真實應用程序並應用一整套工具來改進它。在中間,您將學習有關Python中使用的主要分析器以及一些圖形工具,以幫助您理解其輸出。然後,您將從通用優化技術轉向特定於Python的技術,瀏覽將幫助您提高速度而不需要太多更改的語言主要結構。最後,本書涵蓋了一些特定於數據計算的庫以及如何正確使用它們以獲得最佳速度。

閱讀本書後,您將知道如何對任何Python代碼進行分析,找出瓶頸所在,並應用不同的技術來消除它們。

本書以易於理解、實用的方式指導您通過改進現實世界代碼來提升優化技能。