Python 3 Study Notes (Volume 1) cover

Python 3 Study Notes (Volume 1)

No rating yet
Word count
500 words
Chapters
17
ISBN
9787121332746

Tags

Summary

Python 3 Study Notes (Volume 1) is the language volume of Yuhen's two-volume Python 3 Study Notes. Taking the syntax and runtime of Python 3.6 as its baseline, it begins with how the interpreter works and explains the design background and implementation behind the language. The content stays focused on the language itself: it first outlines CPython's compilation and execution flow and the relationship between names and memory, then works through the underlying behavior of built-in types, the semantics of expressions and assignment, functions and scope, closures and calls, iterators and generators, module and package import mechanisms, and classes, inheritance, multiple inheritance, operator overloading, exceptions, and context management. Beyond basic syntax, the book discusses metaprogramming mechanisms such as decorators, descriptors, and metaclasses in depth, and analyzes interpreter internals including bytecode, the global interpreter lock (GIL), memory allocation, and garbage collection; it also briefly introduces extension approaches such as ctypes and Cython, along with testing and profiling tools including unittest, coverage, timeit, and profile. The author's aim is not to list grammar rules but to help readers see the complex system that is encapsulated and hidden beneath the surface of "simple and easy to use." Compact and principle-oriented throughout, the book suits readers who can already write Python programs and want a deeper understanding of language semantics and interpreter behavior, whether for study or reference.

Editor's review

这不是一本从「print('Hello World')」讲起的入门书,而是一位有二十余年开发经验的老手写下的语言剖析笔记。它的价值在于「往下看一层」:赋值在解释器里发生了什么,闭包与作用域如何绑定,装饰器、描述符与元类怎样借助对象模型工作,导入语句背后要经过怎样的搜索与编译。读完之后,许多平时只会「照着用」的语法规则会突然变得有道理。 第二点是作者的验证方式。书中的结论多来自交互环境中的实验与 CPython 源码对照,而不是照抄语言规范,因此读来常有「原来如此」的顿悟。上卷专注语言,下卷转向标准库,篇幅分工清晰,可以按需取用。 需要提醒的是,本书定位在高阶参考,行文密度大、事例精炼,不适合零基础读者用作第一本教材;出版时基于 Python 3.6,个别实现细节在新版本中已有变化,阅读时宜搭配官方文档对照。总的来说,它是一本适合放在案头、随查随带着「再深入一点」的书。

Who it's for

A good fit for

  • 已能用 Python 写完整项目、想弄清语法背后机制的开发者
  • 需要理解 GIL、字节码、垃圾回收等运行时行为的后端工程师
  • 准备阅读 CPython 源码、希望先建立整体地图的读者
  • 讲授 Python 中高级课程、需要补充原理素材的讲师

Not a good fit for

  • 零基础、尚未写过 Python 程序的学习者
  • 只想快速上手做数据分析或网页开发的读者
  • 希望按部就班做练习、需要大量例题与习题的人

Reading tips

  1. 先通读第1至3章建立解释器与对象模型的全景,再按兴趣跳读后续章节。
  2. 每读到一条结论,打开交互环境亲手复现实验,比被动接受记忆更牢。
  3. 针对当前使用的 Python 版本,用官方文档核对 3.6 之后有变化的行为。
  4. 把它当案头参考书,遇到装饰器、元类、GIL 等问题时定点查阅相关章节。

About the publisher

Publishing House of Electronics Industry China · Founded in 1982

The Publishing House of Electronics Industry is a comprehensive publisher distinguished by its focus on electronic information and related fields. Judging from the more than 3,000 titles in its catalogue, its publishing covers programming and design, artificial intelligence, computer science, finance and economics, photography, and social sciences, attending both to cutting-edge technology and to general readers. Representative titles include Factor Investing: Methods and Practice, x86 Assembly Language: From Real Mode to Protected Mode, The RISC-V Reader, Artificial Intelligence: Speech Recognition, Understanding and Practice, Phased Array Radar Technology, Radar Target Characteristics, and 100 Go Mistakes and How to Avoid Them, most of which centre on technical methods and engineering practice. Its authors include Shi Chuan, Li Zhong, Wang Xiaobo, David Patterson, Andrew Waterman, and Yu Zihao, among others from China and abroad. Owing to limited public information, no further publishing features are elaborated here.

Contents

  1. Chapter 1 Overview
  2. Chapter 2 Types: Basic Environment (Impressions, Names, Memory, Compilation, Execution)
  3. Chapter 2 Built-in Types (Integers, Floats, Strings, Byte Arrays, Lists, Dictionaries, Sets)
  4. Chapter 3 Expressions: Lexical (Source Files, Code)
  5. Chapter 3 Assignment (Augmented Assignment, Sequence Unpacking, Scope)
  6. Chapter 3 Operators (Chained Comparison, Slicing, Logical Operations)
  7. Chapter 3 Control Flow (Selection, Loops)
  8. Chapter 3 Comprehensions
  9. Chapter 4 Functions (Definition, Parameters, Return Values, Scope, Closures, Calls)
  10. Chapter 5 Iterators (Overview, Generators, Patterns, Functional Programming)
  11. Chapter 6 Modules (Definition, Import: Search/Compile/Reference, Packages: Initialization/Relative Imports/Splitting)
  12. Chapter 7 Classes (Definition, Fields, Attributes, Methods, Inheritance, Open Classes, Operator Overloading)
  13. Chapter 8 Exceptions (Overview, Assertions, Context)
  14. Chapter 9 Metaprogramming (Decorators, Descriptors, Metaclasses, Annotations)
  15. Chapter 10 Advanced (Interpreter: Bytecode/GIL/Execution/Memory Allocation/Garbage Collection; Extensions: ctypes, Cython)
  16. Chapter 11 Testing (Unit Testing: unittest, unittest.mock, coverage; Performance Testing: timeit, profile, line profiler, memory profiler, pympler)
  17. Chapter 12 Tools (Debugger, Package Management)

FAQ

这本书适合零基础学 Python 吗?
不太适合。作者明确说明本书着重剖析语言的相关背景与实现方式,面向有一定 Python 编程基础的读者。零基础读者建议先完成一本入门教程并能独立写出完整脚本,再回到本书理解原理。
上卷和下卷分别讲什么?
按出版社介绍,全书分两卷:上卷讲解语言本身,基于 Python 3.6,涵盖类型、表达式、函数、迭代器、模块、类、异常、元编程、解释器进阶与测试工具;下卷分析标准库。两卷分工明确,可按需单独阅读。
书中内容基于哪个 Python 版本?
上卷以 Python 3.6 为基准,出版于 2018 年。CPython 在后续版本中对字节码、错误信息、字典实现等做过调整,遇到与时序或实现细节相关的段落,建议结合当前版本实测与官方文档核对。
为什么不给豆瓣评分?
网络上流传的评分数据口径不一(有 9.2、9.4、6.2 等不同来源),无法确证为本书对应版本的豆瓣评分,因此本书目数据中评分字段留空,建议以豆瓣、出版社等官方页面的实时数据为准。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

More by the same author

Top rated in the same category