Secret Recipes for the Python Ninja: Over 50 recipes that uncover powerful programming tactics in Python

Cody Jackson

商品描述

Test your Python programming skills by solving real world programming problems covered in the book

Key Features

  • Work your way through the standard library and engineer your applications based on appropriate implementations of the library,
  • Discover how to make the best use of decorators, context managers, coroutines and generator functions,
  • Enhance speed and improve concurrency by conjuring up tricks from the Pypy project.

Book Description

Do you feel you've mastered the Python language and you know everything it takes to write applications that are class apart? Well, you're in for a surprise! This book covers the darkest secrets of Python, delving into its depths and uncovering things you never would have thought could be done.

You'll unearth secrets related to the implementation of the standard library, looking at how the modules actually work. Understanding the implementation of collections, decimal, and fractions modules, along with collections.abc and numbers will surely enable you to do much more than you thought possible. If you haven't used decorators, context managers, coroutines, and generator functions enough, you'll learn from their recipes, what you've been missing out on. We'll cover Internal special methods in detail, showing you what they are and how exactly they can be used to improve the engineering decisions you make. Moving on, you'll explore the CPython interpreter, which is a treasure trove of secret hacks that not many programmers have ventured to understand. We'll take you through the depths of the Pypy project where you'll come across several exciting ways that you can use to improve speed and concurrency.

Finally, we'll take the time to explore the PEPs of the latest versions to excavate some interesting hacks.

What You Will Learn

  • Differences between .py files and .pyc files
  • Find out about the different ways to install and upgrade Python packages
  • The working of the PyPi module that enhances built-in decorators
  • Learn how coroutines are different from generators and how they can simulate multithreading
  • How the decimal module improves on floating point numbers and its operations
  • Standardizing subinterpreters to improve concurrency
  • Discovering Python's built-in docstring analyzer

Who This Book Is For

Whether you've been working with Python for a few years or you're a seasoned snake wrangler, you'll have a lot of new tricks to walk away with.

商品描述(中文翻譯)

這本書涵蓋了真實世界的程式設計問題,讓你可以測試自己的 Python 程式設計技巧。

主要特點包括:
- 透過適當的標準程式庫實作,提升應用程式的效能。
- 學習如何最佳運用裝飾器、上下文管理器、協程和生成器函式。
- 從 Pypy 專案中學習加速和改善並行性的技巧。

書籍描述:
你是否覺得自己已經掌握了 Python 語言,並且對於撰寫出優秀應用程式所需的一切都了如指掌?那麼,你將會有所驚喜!本書深入探討 Python 的深層內部,揭示出你從未想過可以實現的事情。

你將會揭開與標準程式庫實作相關的秘密,深入研究模組的實際運作方式。了解 collections、decimal 和 fractions 模組的實作,以及 collections.abc 和 numbers,將使你能夠做出更多超乎你想像的事情。如果你對於裝飾器、上下文管理器、協程和生成器函式的使用還不夠熟悉,你將會從這些範例中學到你所錯過的東西。我們將詳細介紹內部特殊方法,向你展示它們是什麼,以及如何使用它們來改善你所做的工程決策。接下來,你將探索 CPython 解譯器,這是一個寶庫,內含許多很少有程式設計師去理解的秘密技巧。我們將帶你深入 Pypy 專案的內部,讓你發現幾種令人興奮的方式,可以用來提升速度和並行性。

最後,我們將花時間探索最新版本的 PEPs,挖掘一些有趣的技巧。

你將學到:
- .py 檔案和 .pyc 檔案之間的差異。
- 了解不同安裝和升級 Python 套件的方式。
- PyPi 模組的運作方式,以增強內建裝飾器。
- 學習協程與生成器的不同之處,以及它們如何模擬多執行緒。
- decimal 模組如何改進浮點數及其運算。
- 標準化子解譯器以提升並行性。
- 探索 Python 內建的文件字串分析器。

適合對象:
無論你已經使用 Python 幾年還是經驗豐富的開發者,你都將從本書中獲得許多新技巧。