Index

Symbols

A

B

C

D

E

F

G

H

I

  • if clause, 36, 174

  • if statements, 19

  • immutable objects

    • creating, 250–251

    • using in dictionaries and sets, 256–260

  • implicit string concatenation, 62–66

  • imports, 5, 592, 601, 604–605

  • in operator, 117, 119

  • index_words function, 182, 183–184

  • IndexError exception, 336

  • indexing, 72–73. See also slicing

    • negative, 68

    • parallel, 79–80

    • with slicing, 67–69

    • strings, 10–11

  • inheritance

  • inheriting classes for custom container types, 260–264

  • initializing parent classes, 235–236

  • inline negation, 5

  • insert_value, profiling, 448–451

  • insertion ordering, dictionary, 109–116

  • insertion_sort, profiling, 448–451

  • integration tests, 541–542

  • interactive debugging, 565–568

  • interpolated format strings, 56–58

  • I/O

  • isinstance function, 206

  • islice function, 104

  • islice method, 72

  • iter built-in function, 89–91

  • iteration/iterators, 77, 182–183. See also loop/s

    • exception, 88

    • generator, 87

    • lists, 79–80, 87

    • over arguments, 87–92

    • over containers, 95–98

    • over dictionaries, 92–93, 109–116

    • over lists, 94–95

    • over sets, 93, 96

    • passing into generators as arguments, 188–195

    • passing to all built-in function, 98–100

    • passing to any built-in function, 100–101

    • StopIteration exception, 88

    • zip generator, 80–81

  • iterator protocol, 89–92

  • itertools, 72, 185–186

    • accumulate function, 106–107

    • batched function, 105–106

    • chain function, 102

    • combinations function, 108

    • combinations_with_replacement function, 108

    • cycle function, 103

    • dropwhile function, 105

    • filterfalse function, 105

    • islice function, 104

    • pairwise function, 106

    • permutations function, 107

    • product function, 107

    • repeat function, 103

    • takewhile function, 104–105

    • tee function, 103

    • zip_longest function, 81, 103–104

J-K

L

M

N

  • namedtuple function, 259

  • NameError exception, 147

  • negative indexing, 68

  • None, using as default argument value, 157–160

  • nonlocal statement, 148–149

  • normalization function, 87, 89

  • normalize_defensive function, 91–92

  • Numba module, 461

  • Numby module, 461

O

P

  • packages, 588

  • pairwise function, 106

  • parallel indexing, 79–80

  • parallelism, 319

    • concurrent.futures, 393–397

    • data races, preventing, 330–333

    • fan-out, 350–353

    • managing child processes, 320–324

  • parent class

  • parent process, decoupling child process from, 321

  • parentheses

    • assignment expressions, 22–23

    • single-element tuple, 16–19

  • partial function, 171–172

  • patch functions, 555–558

  • PEP 8 (Python Enhancement Proposal #8), 3

    • automation, 5–6

    • expressions and statements, 4–5

    • imports, 5

    • naming, 4

    • whitespace, 3–4

  • performance. See also profiling

    • CPython, 475

    • engineering, 447

    • extension modules, 467–474

    • lazy-loading modules, 478–485

    • loading modules from zip archives, 622–623

    • metrics, 447

    • microbenchmarks, 490–491, 512–517

    • producer–consumer queue, 504–509

    • profiling, 448–453

    • replacing Python with another programming language, 458–462

    • search, 501–503

    • timeit microbenchmarks, 453–458

  • permutations function, 107

  • pickle module, 526–528

    • default attribute values, 528–530

    • stable import paths, 531–532

    • versioning classes, 530–531

  • pip tool, 575–577

  • pipeline, 333–337, 416–417

  • piping data into a subprocess, 321–322

  • pkgutil module, 624–626

  • Point objects, 256–258

  • polymorphism, 207–210, 230–235

  • porting code to use coroutines and asyncio, 368–384

    • bottom-up approach, 387–388

    • top-down approach, 384–387

  • positional arguments, variable, 150–152

  • positional-only arguments, 164–166

  • postmortem debugging, 568–570

  • preemptive multithreading, 325, 331–333

  • pretty method, 209

  • pretty print, 215

  • preventing objects from being modified, 251–254

  • print function, 58–62

  • print_callees method, 452–453

  • print_callers method, 452

  • priority queue, 509–519

  • private attributes, 246–247

  • producer–consumer queue, 504–509

  • producing combinations of items from iterators

    • accumulate function, 106–107

    • batched function, 105–106

    • combinations function, 108

    • combinations_with_replacement function, 108

    • pairwise function, 106

    • permutations function, 107

    • product function, 107

  • product function, 107

  • profiling, 448

    • insertion_sort and insert_value, 448–451

    • print_callees method, 452–453

    • print_callers method, 452

    • utility functions, 451

  • programs. See also code; performance

  • protected attributes, 247–250

  • public attributes, 245–250, 266–269

  • pylint, 6

  • PyPI (Python Package Index), 575

  • Python

    • C extension API, 460, 465

    • knowing the version you’re using, 1–3

    • replacing with another programming language, 458–462

    • support for threads, 327–329

  • Pythonic style, 1

Q

  • quantize method, 525

  • query string parameter, 8–9

  • queue

  • Queue class, 337–344, 353–360

  • quota, leaky-bucket algorithm, 270–273

R

S

T

U

  • underscore (_), 213

  • Unicode

    • to binary conversion, 42

    • code points, 42

    • sandwich, 42–43

  • unit tests, 542–547

  • unittest module, 533–535, 548

  • unpacking, 12–15

  • update method, 96

  • user-defined classes, 137

  • UTC (Coordinated Universal Time), 519

  • utility functions, 451

V

W

X-Y-Z