Index

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

    running totals 367, 368

aggregate function 119

all() function

    using, as reduction 146, 148, 149

Anscombe’s quartet 90

any() function

    using, as reduction 146, 148, 149

Apache httpd 643, 655

API key

    reference link 676

    using 674, 674

Application Program Interface (API) 58

assignment operator

    using, in recursions 254, 255

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

    enumerating 399, 400

    reducing 400, 400, 402, 403

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

    using 426, 426

combinatorial optimization problems 419

Common Log Format (CLF) 600

Communicating Sequential Processes (CSP) paradigm 598

complex decorators

    implementing 534, 535

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

    filtering with 375, 376, 377

concurrency 594

    benefits 597, 597

    boundary conditions 594, 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

    using 560, 561

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

    filter, applying 666, 667

    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

dicttoolz functions 499, 500

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

eager evaluation 47, 48

embarrassingly parallel design 593

enumerate() function 362

    numbers, assigning with 364, 365, 366, 367

    using 171, 172

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

    filtering with 383, 384

    for identifying outliers 204, 205

    for passing or rejecting data 200, 201, 202, 204

filterfalse() function 364

    filtering with 383, 384

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

functional composition 4, 556

    performing, with PyMonad 562, 562, 562, 563

functional hybrid

    example 9, 11

functional paradigm

    classical example 13, 13, 15, 17, 17, 18

    example 6, 7, 8

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

    example 565, 566

G

generator expressions

    applying to scalar functions 142, 142, 143, 145, 146

    applying, to built-in collections 93

    combining 88, 89

    for dicts 94, 95, 96, 96, 98

    for lists 94, 94, 96, 96, 98

    for sets 94, 94, 96, 96, 98

    limitations 86, 87, 88

    using 80, 81, 82, 83, 84, 86

generator functions 82, 85

    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

    writing 273, 274

groupby() function, itertools 363

    iterators, partitioning with 371, 371, 373

H

Haskell 11, 56

higher-level parser 286

higher-order filters

    data structuring 223, 224, 225

    writing 212, 213

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

    writing 275, 276, 277

HTML serialization 673

HTTP request-response model 641, 641, 642

    functional view 646

    server with functional design, considering 645

    services, nesting 647, 648

    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

    with sentinel value 206, 207

iterables

    file, parsing at higher level 127, 128, 129, 130

    items, pairing from sequence 130, 131, 133, 134

    iter() function, using 135, 135, 136

    working with 120, 121, 123

    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

    recipes 388, 388

itertools module, for combinatorics 398

itertoolz functions 494, 496

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

    using 189, 189, 191

last-in-first-out (LIFO) 260

lazy evaluation 47, 48

len() function

    using on collections 150, 151

list comprehension 94

list display 94

ListMonad() monad

    using 567, 568, 569, 570, 571

literal matching

    example 57, 57

low-level parser 284

LRU (Least Recently Used) 446

M

Manhattan distance 405

map-reduce operation

    for sanitizing raw data 465, 466

map() function

    applying 385, 385, 386

    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, by sorting 267, 268

    building, with Counter 264, 266

    creating, with bisect module 102

mappings 118

Markov chain 573

match statement 57

max() function

    using 183, 185, 185, 187, 188

memoization

    with @cache and @lru_cache 446, 447, 448, 449

middleware 655

Miller-Rabin primality tests 49

min() function

    using 183, 184, 185, 187, 188

monad bind() function 572

monads 60, 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

    analysis process 613, 614

    large files, processing 600, 601, 602

    log files, parsing 603, 603

    log lines, parsing into named tuples 604, 604, 605, 606, 607

    rows, gathering 603, 603

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 78, 78, 79

    using for data collection 300, 302, 303, 303, 305, 305

Newton-Raphson algorithm 13

NGINX 643, 655

non-strict evaluation 46, 47

nonlocal statement 4

normalization 152

numerical recursions 242, 244

    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

    reducing with 491, 492, 493

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

    writing 38, 39

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

recursion 49, 50, 51, 54, 55

    collection folding 255

    examples 6, 7, 8

    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

    usage, tracking 673, 674, 675

reversed() function

    using 169, 169, 171

S

Scala 56

scalar functions 119, 142

secrets module 675

Secure Socket Layer (SSL) protocols 645

sequences

    flattening 161, 161, 162

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

    using 169, 169, 171

Spearman rank correlation 321

    computing 326, 327, 328, 329, 330

stacks, abstractions 12, 12

starmap() function, itertools 364, 486

    applying 384, 385, 386

starmap(function, iterable) method, Pool object 617

state 3

stateful mappings

    using 98, 99, 101, 102

stateful sets

    using 104, 104

statistics

    sums and counts, using 152, 152, 153, 154, 156, 156

Strategy design pattern 73, 74, 75

strict evaluation 45

strings 76, 76, 77

subsets

    picking, with islice() function 377, 378, 380

sum() function

    using on collections 150, 151

sum_to() function 48

T

tail recursion

    example 54

tail-call optimization

    deques, using 258, 259, 260, 261

    for collections 252, 253, 254

    handling 248, 249, 250

    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

    dicttoolz functions 499, 500

    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 77, 78, 79

    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

    using 254, 255

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

    using 43, 44

wrap-unwrap design pattern 320

X

XML Schema Definition (XSD) 672

XML serialization 672

Z

zip() function 157

    example 157, 158

zip_longest() function, itertools 363

    iterables, merging with 373

zipped sequence

    unzipping 160, 160

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.23.130