注冊(cè) | 登錄讀書(shū)好,好讀書(shū),讀好書(shū)!
讀書(shū)網(wǎng)-DuShu.com
當(dāng)前位置: 首頁(yè)出版圖書(shū)科學(xué)技術(shù)計(jì)算機(jī)/網(wǎng)絡(luò)軟件與程序設(shè)計(jì)Effective Python:改善Python程序的90個(gè)建議(第2版 英文版)

Effective Python:改善Python程序的90個(gè)建議(第2版 英文版)

Effective Python:改善Python程序的90個(gè)建議(第2版 英文版)

定 價(jià):¥128.00

作 者: 暫缺
出版社: 電子工業(yè)出版社
叢編項(xiàng):
標(biāo) 簽: 暫缺

購(gòu)買(mǎi)這本書(shū)可以去


ISBN: 9787121386930 出版時(shí)間: 2020-06-01 包裝: 平裝
開(kāi)本: 16 頁(yè)數(shù): 字?jǐn)?shù):  

內(nèi)容簡(jiǎn)介

  Brett Slatkin根據(jù)自己在Google公司多年開(kāi)發(fā)Python基礎(chǔ)架構(gòu)所積累的經(jīng)驗(yàn),揭示了Python語(yǔ)言中一些鮮為人知的微妙特性,并給出了能夠改善代碼功能及運(yùn)行效率的習(xí)慣用法。書(shū)中匯聚了90個(gè)優(yōu)秀的實(shí)踐原則、開(kāi)發(fā)技巧和便捷方案,并以實(shí)用的代碼范例來(lái)解釋它們。通過(guò)本書(shū),你能夠了解到解決關(guān)鍵編程任務(wù)的實(shí)用技巧,并學(xué)會(huì)編寫(xiě)易于理解、便于維護(hù)且利于改進(jìn)的代碼。除此之外,本書(shū)第2版基本上修改了第1版中的所有條目,以反映Python實(shí)踐的演變歷程。

作者簡(jiǎn)介

  Brett Slatkin,Gooqle公司不錯(cuò)軟件工程師。他是Google消費(fèi)者調(diào)查項(xiàng)目的工程主管及聯(lián)合創(chuàng)始人,曾從事Google App Engine的Python基礎(chǔ)架構(gòu)工作,并利用Python來(lái)管理眾多的Google服務(wù)器。Slatkin也是PubSubHubbub協(xié)議的聯(lián)合創(chuàng)始人,還用Python為GoogIe實(shí)現(xiàn)了針對(duì)該協(xié)議的系統(tǒng)。他擁有哥倫比亞大學(xué)計(jì)算機(jī)工程專(zhuān)業(yè)學(xué)士學(xué)位。 Brett Slaktin,Google首席軟件工程師、Google消費(fèi)者調(diào)查項(xiàng)目工程主管及聯(lián)合創(chuàng)始人、PubSubHubbub 協(xié)議聯(lián)合創(chuàng)始人。他啟動(dòng)了Google第一個(gè)云計(jì)算產(chǎn)品App Engine。十四年前,他在實(shí)習(xí)時(shí)使用Python管理了Google大量的服務(wù)器。在日常工作之余,他喜歡彈鋼琴和沖浪。他也喜歡在自己的網(wǎng)站上發(fā)布一些編程相關(guān)的話題和文章。他擁有紐約市哥倫比亞大學(xué)計(jì)算機(jī)工程學(xué)士學(xué)位?,F(xiàn)居舊金山。

圖書(shū)目錄

Chapter 1 Pythonic Thinking 1
Item 1: Know Which Version of Python You’re Using 1
Item 2: Follow the PEP 8 Style Guide 2
Item 3: Know the Differences Between bytes and str 5
Item 4: Prefer Interpolated F-Strings Over C-style
Format Strings and str.format 11
Item 5: Write Helper Functions Instead of
Complex Expressions 21
Item 6: Prefer Multiple Assignment Unpacking
Over Indexing 24
Item 7: Prefer enumerate Over range 28
Item 8: Use zip to Process Iterators in Parallel 30
Item 9: Avoid else Blocks After for and while Loops 32
Item 10: Prevent Repetition with Assignment Expressions 35
Chapter 2 Lists and Dictionaries 43
Item 11: Know How to Slice Sequences 43
Item 12: Avoid Striding and Slicing in a Single Expression 46
Item 13: Prefer Catch-All Unpacking Over Slicing 48
Item 14: Sort by Complex Criteria Using the key Parameter 52
Item 15: Be Cautious When Relying on dict
Insertion Ordering 58
Item 16: Prefer get Over in and KeyError to
Handle Missing Dictionary Keys 65
Item 17: Prefer defaultdict Over setdefault to
Handle Missing Items in Internal State 70
Item 18: Know How to Construct Key-Dependent
Default Values with __missing__ 73
Chapter 3 Functions 77
Item 19: Never Unpack More Than Three Variables
When Functions Return Multiple Values 77
Item 20: Prefer Raising Exceptions to Returning None 80
Item 21: Know How Closures Interact with Variable Scope 83
Item 22: Reduce Visual Noise with Variable
Positional Arguments 87
Item 23: Provide Optional Behavior with Keyword Arguments 90
Item 24: Use None and Docstrings to Specify
Dynamic Default Arguments 94
Item 25: Enforce Clarity with Keyword-Only and
Positional-Only Arguments 97
Item 26: Define Function Decorators with functools.wraps 102
Chapter 4 Comprehensions and Generators 107
Item 27: Use Comprehensions Instead of map and filter 107
Item 28: Avoid More Than Two Control Subexpressions in
Comprehensions 109
Item 29: Avoid Repeated Work in Comprehensions by Using
Assignment Expressions 111
Item 30: Consider Generators Instead of Returning Lists 114
Item 31: Be Defensive When Iterating Over Arguments 117
Item 32: Consider Generator Expressions for Large List
Comprehensions 122
Item 33: Compose Multiple Generators with yield from 124
Item 34: Avoid Injecting Data into Generators with send 127
Item 35: Avoid Causing State Transitions in
Generators with throw 133
Item 36: Consider itertools for Working with Iterators
and Generators 138
Chapter 5 Classes and Interfaces 145
Item 37: Compose Classes Instead of Nesting
Many Levels of Built-in Types 145
Item 38: Accept Functions Instead of Classes for
Simple Interfaces 152
Item 39: Use @classmethod Polymorphism to
Construct Objects Generically 155
Item 40: Initialize Parent Classes with super 160
Item 41: Consider Composing Functionality
with Mix-in Classes 165
Item 42: Prefer Public Attributes Over Private Ones 170
Item 43: Inherit from collections.abc for
Custom Container Types 175
Chapter 6 Metaclasses and Attributes 181
Item 44: Use Plain Attributes Instead of Setter and
Getter Methods 181
Item 45: Consider @property Instead of
Refactoring Attributes 186
Item 46: Use Descriptors for Reusable @property Methods 190
Item 47: Use __getattr__, __getattribute__, and
__setattr__ for Lazy Attributes 195
Item 48: Validate Subclasses with __init_subclass__ 201
Item 49: Register Class Existence with __init_subclass__ 208
Item 50: Annotate Class Attributes with __set_name__ 214
Item 51: Prefer Class Decorators Over Metaclasses for
Composable Class Extensions 218
Chapter 7 Concurrency and Parallelism 225
Item 52: Use subprocess to Manage Child Processes 226
Item 53: Use Threads for Blocking I/O, Avoid for Parallelism 230
Item 54: Use Lock to Prevent Data Races in Threads 235
Item 55: Use Queue to Coordinate Work Between Threads 238
Item 56: Know How to Recognize When Concurrency
Is Necessary 248
Item 57: Avoid Creating New Thread Instances for
On-demand Fan-out 252
Item 58: Understand How Using Queue for
Concurrency Requires Refactoring 257
Item 59: Consider ThreadPoolExecutor When Threads
Are Necessary for Concurrency 264
Item 60: Achieve Highly Concurrent I/O with Coroutines 266
Item 61: Know How to Port Threaded I/O to asyncio 271
Item 62: Mix Threads and Coroutines to Ease the
Transition to asyncio 282
Item 63: Avoid Blocking the asyncio Event Loop to
Maximize Responsiveness 289
Item 64: Consider concurrent.futures for True Parallelism 292
Chapter 8 Robustness and Performance 299
Item 65: Take Advantage of Each Block in try/except
/else/finally 299
Item 66: Consider contextlib and with Statements
for Reusable try/finally Behavior 304
Item 67: Use datetime Instead of time for Local Clocks 308
Item 68: Make pickle Reliable with copyreg 312
Item 69: Use decimal When Precision Is Paramount 319
Item 70: Profile Before Optimizing 322
Item 71: Prefer deque for Producer?CConsumer Queues 326
Item 72: Consider Searching Sorted Sequences with bisect 334
Item 73: Know How to Use heapq for Priority Queues 336
Item 74: Consider memoryview and bytearray for
Zero-Copy Interactions with bytes 346
Chapter 9 Testing and Debugging 353
Item 75: Use repr Strings for Debugging Output 354
Item 76: Verify Related Behaviors in TestCase Subclasses 357
Item 77: Isolate Tests from Each Other with setUp,
tearDown, setUpModule, and tearDownModule 365
Item 78: Use Mocks to Test Code with
Complex Dependencies 367
Item 79: Encapsulate Dependencies to Facilitate
Mocking and Testing 375
Item 80: Consider Interactive Debugging with pdb 379
Item 81: Use tracemalloc to Understand Memory
Usage and Leaks 384
Chapter 10 Collaboration 389
Item 82: Know Where to Find Community-Built Modules 389
Item 83: Use Virtual Environments for Isolated and
Reproducible Dependencies 390
Item 84: Write Docstrings for Every Function,
Class, and Module 396
Item 85: Use Packages to Organize Modules and
Provide Stable APIs 401
Item 86: Consider Module-Scoped Code to
Configure Deployment Environments 406
Item 87: Define a Root Exception to Insulate
Callers from APIs 408
Item 88: Know How to Break Circular Dependencies 413
Item 89: Consider warnings to Refactor and Migrate Usage 418
Item 90: Consider Static Analysis via typing to Obviate Bugs 425
Index 435

本目錄推薦

掃描二維碼
Copyright ? 讀書(shū)網(wǎng) www.talentonion.com 2005-2020, All Rights Reserved.
鄂ICP備15019699號(hào) 鄂公網(wǎng)安備 42010302001612號(hào)