As this ebook edition doesn't have fixed pagination, the page numbers below are hyperlinked for reference only, based on the printed edition of this book.
Symbols
@cache decorator 443
for memoization 445, 446, 448, 449
@functoolz.memoize decorator 501
@lru_cache decorator 443
for memoization 446, 446, 448, 449
@singledispatch decorator 473, 474, 475
@total_ordering decorator 443
classes, defining with 450, 451, 451, 452
@wraps decorator 517
A
Accretion design pattern 121
accumulate() function 362
aggregate function 119
all() function
using, as reduction 146, 148, 149
Anscombe’s quartet 90
any() function
using, as reduction 146, 148, 149
API key
reference link 676
Application Program Interface (API) 58
assignment operator
assignment statement 4
asyncio module 623
B
Bird-Meertens Formalism 256
bisect module
used, for mapping 102, 103, 103
build_duplicates() function 325
C
callables 226
higher-order functions, building with 226, 227
Cartesian product
chain() function, itertools 363
iterators, combining with 369, 370
chunking 223
class statement 4
Clojure 98
collection functions 119
filter 120
mapping 119
reduction 119
collections
len() and sum(), using 150, 151
processing, through recursion 250, 251
tail-call optimization 252, 252, 254
combinations
generating 422, 423, 424, 425, 425
combinations() function, itertools 398
combinations_with_replacement() function, itertools 398
combinatorial optimization problems 419
Common Log Format (CLF) 600
Communicating Sequential Processes (CSP) paradigm 598
complex decorators
complicated object initialization
implementing 310, 312, 313, 314
composite function 513, 523, 525, 526
bad data, preprocessing 527, 527, 528, 529
compress() function, itertools 363
concurrency 594
resources, sharing with process or threads 595, 596
consumer 620
cookies 643
coprime 49
count() function
counting with 346
count() function, itertools 346
counting with 347
float arguments, counting with 349, 350, 351, 354
cross-cutting concerns 522
Cross-Site Request Forgeries (CSRF) 647
CSV serializer 672
CSV-based parser 281, 282, 282, 283
curl 641
curried higher-order functions
currying 60, 192, 453, 556, 556, 557, 559
cycle() function, itertools 346
cycle, re-iterating with 355, 358
for data sampling 358, 359, 360
D
data
collecting, with NamedTuple 300
collecting, with pyrsistent 315, 315, 316, 318, 318, 319
collecting, with tuples 295, 297, 299
data access tier, web service 665, 665, 666
data, serializing with JSON or CSV formats 671, 672
data, serializing with XML and HTML 672, 673
results, serializing 668, 670, 671
data sets
reducing, with reduce() function 457, 458, 460, 460
De Morgan’s Law 148
decorators 513
as higher-order functions 514, 515, 517, 518, 519, 520
complicated design considerations 535, 537, 538, 539, 540, 542
parameter, adding 530, 531, 532, 533, 534
def statement 4
deques
used, for tail-call optimization 258, 259, 260, 261
distances
computing 403, 404, 405, 406, 408
divide and conquer strategy 74, 247
Django 656
double factorial 489
dropwhile() function, itertools 364
stateful filtering 381, 382, 382
E
embarrassingly parallel design 593
enumerate() function 362
numbers, assigning with 364, 365, 366, 367
Erlang 11
Euclidean distance 404
exploratory data analysis (EDA) 2, 19
data exploration 20
data modeling and machine learning 20
data preparation 19
evaluation 20
stages 20
F
Fibonacci numbers 248
file parsers
CSV files, parsing 281, 282, 282, 283
plain text files, parsing with headers 284, 285, 285, 286
writing 277, 278, 279, 279, 281
filter() function
for identifying outliers 204, 205
for passing or rejecting data 200, 201, 202, 204
filterfalse() function 364
finite iterators 362
first normal form 279
first-in-first-out (FIFO) 260
Flask 656
Flask application
processing 659, 660, 662, 663, 664
flat sequences
structuring 163, 164, 165, 165
structuring, alternative approach 166, 168
free variable 69
frozen dataclasses
using for data collection 306, 307, 308, 309
function evaluation 4
performing, with PyMonad 562, 562, 562, 563
functional hybrid
functional paradigm
classical example 13, 13, 15, 17, 17, 18
functional style
versus procedural style 5
functional type systems 56, 57
functions
as first-class objects 37, 37, 72, 73, 74, 75
collection functions 119
higher-order functions 40
pure functions 38
scalar functions 119
functools module 443
functoolz functions 501
'@functoolz.memoize decorator 501
functoolz.compose() 502
functoolz.compose() function 504
functoolz.compose_left() function 504
functoolz.curry() function 502
functoolz.pipe() function 504
functor 564
G
generator expressions
applying to scalar functions 142, 142, 143, 145, 146
applying, to built-in collections 93
raw data, cleaning with 90, 90, 92
Global Interpreter Lock (GIL) 592
global statement 4
group-by reduction
data partitioning, by key values 268, 269, 270, 271, 272
file parsers, writing 277, 278, 279, 279, 280
from many items to fewer 261, 262, 263
mapping, building by sorting 267, 268
mapping, building with Counter 264, 266
groupby() function, itertools 363
iterators, partitioning with 371, 371, 373
H
higher-level parser 286
higher-order filters
data structuring 223, 224, 225
higher-order functions 40, 181
building, with callables 226, 227
collection, materializing 232
collection, reducing 232
design patterns, reviewing 231, 232
filter() function 200
functional design, assuring 228, 228, 229
generator, acting as 232
generator, returning 231
iter() function 206
map() function 192
max() function 183
min() function 183
scalar 232
sorted() function 207
using 43
writing 210
higher-order mappings
additional data, unwrapping 218, 219, 219, 220
data unwrapping 215, 216, 217, 218
data, flattening 221, 222, 223
writing 211
higher-order reduction
HTML serialization 673
HTTP request-response model 641, 641, 642
functional view 646
server with functional design, considering 645
state, injecting through cookies 643
I
imap(function, iterable) method, Pool object 617
imap_unordered(function, iterable) method, Pool object 617
immutable objects 42
imperative statement 3
import statement 4
infinite iterators
count() function, counting with 346, 347
counting, with float arguments 349, 350, 351, 354
cycle, re-iterating with cycle() function 355, 358
cycle() function, for data sampling 358, 359, 360
value, repeating with repeat() function 360, 361, 362
working with 345
islice() function, itertools 363
subsets, picking with 377, 378, 380
iter() function
iterables
file, parsing at higher level 127, 128, 129, 130
items, pairing from sequence 130, 131, 133, 134
iter() function, using 135, 135, 136
XML file, parsing 123, 124, 125, 126
iteration
extending 137, 137, 139, 140, 141
iterator functions 343
iterators
cloning, with tee() function 386
combining, with chain() function 369, 370
finite iterators 362
infinite iterators 346
partitioning, with groupby() function 371, 371, 373
itertools module 345
itertools module, for combinatorics 398
J
JavaScript Object Notation (JSON) 127
JSON serializer 671
K
k-Nearest Neighbors (k-NN) algorithm 403
L
lambda calculus 192
lambda forms
map() function, working with 195
last-in-first-out (LIFO) 260
len() function
list comprehension 94
list display 94
ListMonad() monad
literal matching
low-level parser 284
LRU (Least Recently Used) 446
M
Manhattan distance 405
map-reduce operation
for sanitizing raw data 465, 466
map() function
for applying function to collection 192, 193
lambda forms, working with 195, 196
using, with multiple sequences 196, 197, 199
map(function, iterable) method, Pool object 616
mapping
building, with Counter 264, 266
creating, with bisect module 102
mappings 118
Markov chain 573
match statement 57
max() function
memoization
with @cache and @lru_cache 446, 447, 448, 449
middleware 655
Miller-Rabin primality tests 49
min() function
monad bind() function 572
simulation, implementing with 573, 577, 578, 579, 580
Monte Carlo simulation 573
mr-proper tool 38
multiprocessing application
access details, analyzing 612, 613
access details, filtering 610, 612
additional fields of Access object, parsing 607, 608, 608, 609
large files, processing 600, 601, 602
log lines, parsing into named tuples 604, 604, 605, 606, 607
multiprocessing package
Pool object 598
multiprocessing pool, for concurrent processing 614, 615, 616, 617, 618
apply(), for making single request 619
async functions, using 623, 625
complex architectures 619
concurrent processing, designing 625, 627, 629, 630
concurrent.futures module, using 620, 620
concurrent.futures thread pools, using 621, 622
queue modules, using 623
threading modules, using 622
Multipurpose Internet Mail Extension (MIME) 646
mypy tool 3, 57, 96, 153, 261, 270, 308, 332, 650
N
named tuples
using for data collection 300, 302, 303, 303, 305, 305
Newton-Raphson algorithm 13
nonlocal statement 4
normalization 152
assignment operator, using 254, 255
collections, processing through 250, 251
divide and conquer strategy 247, 248
manual tail-call optimization, implementing 244, 246
tail-call optimization, handling 248, 249, 250
O
Object-Oriented Programming (OOP) 45, 228, 230, 293, 610
OCaml 11
operator module functions
P
pairwise() function, itertools
pairs, creating with 374
parameterized decorator 530, 531, 532, 533, 534
partial application 453
partial() function, functools 444
partial arguments, applying with 453, 455, 456
Peano axioms 242
performance improvements 410, 412, 414, 415
transformations, combining 417, 418, 418
permutations() function, itertools 398
used, for collection of values 419, 420, 421
pixels and colors
enumerating, with product() function 408, 409
polymorphism 331, 333, 334, 335, 335
Pool object 598
predicate function 200
prime number
definition 49
procedural style
versus functional style 5
producer 620
product() function, itertools 398
pixels and colors, enumerating with 408, 409
pure function
pylint tool 580
PyMonad library 60
PyMonad package 555
features 581
functional composition, performing with 562, 563
installing 555
pyrsistent
using, for data collection 315, 315, 317, 318, 318, 319
pytest tool 261
Python Imaging Library (PIL) 402
Python Package Index (PyPI) 555
Q
quartile 368
queue module 623
R
railroad diagram 604
raw data
cleaning with generator functions 90, 90, 92
collection folding 255
simple numerical 242
reduce() function
combining, with map() function 461, 461, 462
data sets, reducing with 456, 458, 460, 460
limitation 465
problems avoiding 472
using, with groupby() function 468, 469, 470, 471
using, with partial() function 463, 463
reduce() function, functools 444
reductions 118
collection, folding from many to one 255, 256, 257
group-by reduction 261, 262, 263
tail-call optimization, deques used 258, 259, 260, 261
referential transparency 60
registry 513
repeat() function, itertools
single value, repeating with 360, 361, 362
Representational State Transfer (REST) 639
RESTful web service 644
data access tier 664, 665, 666
defining, as functions 656, 657, 659
Flask application processing 659, 660, 662, 662, 664
reversed() function
S
Scala 56
secrets module 675
Secure Socket Layer (SSL) protocols 645
sequences
serialization 668
session 644
short-circuit operators 46
Sieve of Eratosthenes algorithm 204
simulation
implementing, with monads 572, 577, 578, 579, 580
singledispatch() function, functools 444
sorted() function
used, for data sorting 207, 208
Spearman rank correlation 321
computing 326, 327, 328, 329, 330
starmap() function, itertools 364, 486
starmap(function, iterable) method, Pool object 617
state 3
stateful mappings
stateful sets
statistics
sums and counts, using 152, 152, 153, 154, 156, 156
Strategy design pattern 73, 74, 75
strict evaluation 45
subsets
picking, with islice() function 377, 378, 380
sum() function
sum_to() function 48
T
tail recursion
example 54
tail-call optimization
deques, using 258, 259, 260, 261
manual implementation 245, 246
takewhile() function, itertools 364
stateful filtering 381, 382, 382
tee() function, itertools
iterators, cloning with 386
threading module 623
toolz package 485
functoolz functions 501, 502, 504, 504
itertoolz functions 494, 494, 496, 497, 498, 498
using 493
tox tool 261
Trial Division algorithm 49
tuples
used, for avoiding stateful classes 320, 321, 322, 323, 325, 325, 326
using for data collection 294, 297, 299
two-tier parser 286
type pattern matching 331, 333, 334, 335, 335
U
unwrapping-while-mapping design pattern 216
update_wrapper() function, functools 521
user experience (UX) design 641
W
walrus operator
Web Server Gateway Interface (WSGI) standard 649, 649, 650, 651, 652, 652
exceptions, raising 653, 653, 654
pragmatic web applications 655, 656
werkzeug.wsgi module 650
wget 641
wrap-process-unwrap pattern
wrap-unwrap design pattern 320
X
XML Schema Definition (XSD) 672
XML serialization 672
Z
zip() function 157
zip_longest() function, itertools 363
iterables, merging with 373
zipped sequence