High Performance Python. 3rd Edition - Helion

ISBN: 9781098165925
stron: 524, Format: ebook
Data wydania: 2025-04-29
Księgarnia: Helion
Cena książki: 186,15 zł (poprzednio: 227,01 zł)
Oszczędzasz: 18% (-40,86 zł)
Your Python code may run correctly, but what if you need it to run faster? This practical book shows you how to locate performance bottlenecks and significantly speed up your code in high-data-volume programs. By explaining the fundamental theory behind design choices, this expanded edition of High Performance Python helps experienced Python programmers gain a deeper understanding of Python's implementation.
How do you take advantage of multicore architectures or compilation? Or build a system that scales up beyond RAM limits or with a GPU? Authors Micha Gorelick and Ian Ozsvald reveal concrete solutions to many issues and include war stories from companies that use high-performance Python for GenAI data extraction, productionized machine learning, and more.
- Get a better grasp of NumPy, Cython, and profilers
- Learn how Python abstracts the underlying computer architecture
- Use profiling to find bottlenecks in CPU time and memory usage
- Write efficient programs by choosing appropriate data structures
- Speed up matrix and vector computations
- Process DataFrames quickly with Pandas, Dask, and Polars
- Speed up your neural networks and GPU computations
- Use tools to compile Python down to machine code
- Manage multiple I/O and computational operations concurrently
- Convert multiprocessing code to run on local or remote clusters
Osoby które kupowały "High Performance Python. 3rd Edition", wybierały także:
- Windows Media Center. Domowe centrum rozrywki 66,67 zł, (8,00 zł -88%)
- Ruby on Rails. Ćwiczenia 18,75 zł, (3,00 zł -84%)
- Efekt piaskownicy. Jak szefować żeby roboty nie zabrały ci roboty 59,50 zł, (11,90 zł -80%)
- Przywództwo w świecie VUCA. Jak być skutecznym liderem w niepewnym środowisku 58,64 zł, (12,90 zł -78%)
- Scrum. O zwinnym zarządzaniu projektami. Wydanie II rozszerzone 58,64 zł, (12,90 zł -78%)
Spis treści
High Performance Python. 3rd Edition eBook -- spis treści
- Foreword
- Preface
- Who This Book Is For
- Who This Book Is Not For
- What Youll Learn
- Python 3
- License
- How to Make an Attribution
- Using Code Examples
- Errata and Feedback
- Conventions Used in This Book
- OReilly Online Learning
- How to Contact Us
- Acknowledgments
- 1. Understanding Performant Python
- The Fundamental Computer System
- Computing Units
- Memory Units
- Communications Layers
- Idealized Computing Versus the Python Virtual Machine
- Idealized Computing
- Pythons Virtual Machine
- So Why Use Python?
- How to Be a Highly Performant Programmer
- Good Working Practices
- Optimizing for the Team Rather than the Code Block
- The Remote Performant Programmer
- Some Thoughts on Good Notebook Practice
- Your Work
- The Future of Python
- Where Did the GIL Go?
- Does Python Have a JIT?
- Wrap-Up
- The Fundamental Computer System
- 2. Profiling to Find Bottlenecks
- Profiling Efficiently
- Introducing the Julia Set
- Calculating the Full Julia Set
- Simple Approaches to Timingprint and a Decorator
- Simple Timing Using the Unix time Command
- Using the cProfile Module
- Visualizing cProfile Output with SnakeViz
- Using line_profiler for Line-by-Line Measurements
- Using memory_profiler to Diagnose Memory Usage
- Combining CPU and Memory Profiling with Scalene
- Introspecting an Existing Process with PySpy
- VizTracer for an Interactive Time-Based Call Stack
- Bytecode: Under the Hood
- Using the dis Module to Examine CPython Bytecode
- Digging into Bytecode Specialization with Specialist
- Different Approaches, Different Complexity
- Unit Testing During Optimization to Maintain Correctness
- No-op @profile Decorator
- Strategies to Profile Your Code Successfully
- Wrap-Up
- 3. Lists and Tuples
- A More Efficient Search
- Lists Versus Tuples
- Lists as Dynamic Arrays
- Tuples as Static Arrays
- Wrap-Up
- 4. Dictionaries and Sets
- How Do Dictionaries and Sets Work?
- Inserting and Retrieving
- Deletion
- Resizing
- Hash Functions and Entropy
- Wrap-Up
- How Do Dictionaries and Sets Work?
- 5. Iterators and Generators
- Iterators for Infinite Series
- Lazy Generator Evaluation
- Wrap-Up
- 6. Matrix and Vector Computation
- Introduction to the Problem
- Arent Python Lists Good Enough?
- Problems with Allocating Too Much
- Memory Fragmentation
- Understanding perf
- Making Decisions with perfs Output
- Enter numpy
- Applying numpy to the Diffusion Problem
- Memory Allocations and In-Place Operations
- Selective Optimizations: Finding What Needs to Be Fixed
- numexpr: Making In-Place Operations Faster and Easier
- Graphics Processing Units (GPUs)
- Dynamic Graphs: PyTorch
- GPU Speed and Numerical Precision
- GPU-Specific Operations
- Basic GPU Profiling
- Performance Considerations of GPUs
- When to Use GPUs
- Deep Learning Performance Considerations
- Automatic Mixed-Precision
- Model quantization
- Model or data distribution
- JIT
- A Cautionary Tale: Verify Optimizations (scipy)
- Lessons from Matrix Optimizations
- Wrap-Up
- 7. Pandas, Dask, and Polars
- Pandas
- Pandass Internal Model
- Arrow and NumPy
- Applying a Function to Many Rows of Data
- Which OLS implementation should we use?
- Applying lstsq to our rows of data
- Numba to Compile NumPy for Pandas
- Building from Partial Results Rather than Concatenating
- Theres More Than One (and Possibly a Faster) Way to Do a Job
- Advice for Effective Pandas Development
- Dask for Distributed Data Structures and DataFrames
- Diagnostics
- Parallel Pandas with Dask
- Dask Expressions
- Parallelized computations
- Parallelized apply with Swifter on Dask
- Polars for Fast DataFrames
- Wrap-Up
- Pandas
- 8. Compiling to C
- What Sort of Speed Gains Are Possible?
- JIT Versus AOT Compilers
- Why Does Type Information Help the Code Run Faster?
- Using a C Compiler
- Reviewing the Julia Set Example
- Cython
- Compiling a Pure Python Version Using Cython
- pyximport
- Cython Annotations to Analyze a Block of Code
- Adding Some Type Annotations
- Cython and numpy
- Parallelizing the Solution with OpenMP on One Machine
- Numba
- PyPy
- Garbage Collection Differences
- Running PyPy and Installing Modules
- A Summary of Speed Improvements
- When to Use Each Technology
- Foreign Function Interfaces
- ctypes
- cffi
- f2py
- CPython Extensions: C
- CPython Extensions: Rust
- Creating a Python extension with Rust
- Writing the extension
- Installing and using the extension
- Wrap-Up
- 9. Asynchronous I/O
- Introduction to Asynchronous Programming
- How Does async/await Work?
- Serial Web Crawler
- Asynchronous Web Crawler
- Shared CPUI/O Workload
- Serial CPU Workload
- Batched CPU Workload
- Fully Asynchronous CPU Workload
- Wrap-Up
- 10. The multiprocessing Module
- An Overview of the multiprocessing Module
- Estimating Pi Using the Monte Carlo Method
- Estimating Pi Using Processes and Threads
- Using Python Objects
- Replacing multiprocessing with Joblib
- Intelligent caching of function call results
- Random Numbers in Parallel Systems
- Using numpy
- Finding Prime Numbers
- Queues of Work
- Asynchronously Adding Jobs to the Queue
- Verifying Primes Using Interprocess Communication
- Serial Solution
- Naive Pool Solution
- A Less Naive Pool Solution
- Using manager.Value as a Flag
- Using Redis as a Flag
- Using RawValue as a Flag
- Using mmap as a Flag
- Using mmap as a Flag Redux
- Sharing numpy Data with multiprocessing
- Synchronizing File and Variable Access
- File Locking
- Locking a Value
- Wrap-Up
- 11. Clusters and Job Queues
- Benefits of Clustering
- Drawbacks of Clustering
- $462 Million Wall Street Loss Through Poor Cluster Upgrade Strategy
- Skypes 24-Hour Global Outage
- Common Cluster Designs
- How to Start a Clustered Solution
- Ways to Avoid Pain When Using Clusters
- Two Clustering Solutions
- Using IPython Parallel to Support Research
- Message Brokering for Cluster Efficiency
- Queue
- Pub/sub
- Other Clustering Tools to Look At
- Docker
- Dockers Performance
- Advantages of Docker
- Wrap-Up
- 12. Using Less RAM
- Objects for Primitives Are Expensive
- The array Module Stores Many Primitive Objects Cheaply
- Using Less RAM in NumPy with NumExpr
- Understanding the RAM Used in a Collection
- Bytes Versus Unicode
- Efficiently Storing Lots of Text in RAM
- Trying These Approaches on 11 Million Tokens
- list
- set
- dict
- More efficient tree structures
- Marisa trie
- Using tries in production systems
- Trying These Approaches on 11 Million Tokens
- Modeling More Text with scikit-learns FeatureHasher
- Introducing DictVectorizer and FeatureHasher
- Comparing DictVectorizer and FeatureHasher on a Real Problem
- SciPys Sparse Matrices
- Tips for Using Less RAM
- Probabilistic Data Structures
- Very Approximate Counting with a 1-Byte Morris Counter
- K-Minimum Values
- Bloom Filters
- LogLog Counter
- Real-World Example
- Wrap-Up
- Objects for Primitives Are Expensive
- 13. Lessons from the Field
- Developing a High Performance Machine Learning Algorithm
- High Performance Computing in Journalism
- Lessons from the Field of Cyber Reinsurance
- Python in Quant Finance
- Maintain Flexibility to Achieve High Performance
- Streamlining Feature Engineering Pipelines with Feature-engine (2020)
- Highly Performant Data Science Teams (2020)
- Numba (2020)
- Optimizing Versus Thinking (2020)
- Making Deep Learning Fly with RadimRehurek.com (2014)
- Large-Scale Social Media Analysis at Smesh (2014)
- Index