Cargando…

Mastering Python high performance : measure, optimize, and improve the performance of your Python code with this easy-to-follow guide /

Measure, optimize, and improve the performance of your Python code with this easy-to-follow guide About This Book Master the do's and don'ts of Python performance programming Learn how to use exiting new tools that will help you improve your scripts A step-by-step, conceptual guide to teac...

Descripción completa

Detalles Bibliográficos
Clasificación:Libro Electrónico
Autor principal: Doglio, Fernando (Autor)
Formato: Electrónico eBook
Idioma:Inglés
Publicado: Birmingham, UK : Packt Publishing, [2015]
Colección:Community experience distilled.
Temas:
Acceso en línea:Texto completo (Requiere registro previo con correo institucional)
Tabla de Contenidos:
  • Cover; Copyright; Credits; About the Author; About the Reviewers; www.PacktPub.com; Table of Contents; Preface; Chapter 1: Profiling 101; What is profiling?; Event-based profiling; Statistical profiling; The importance of profiling; What can we profile?; Execution time; Where are the bottlenecks?; Memory consumption and memory leaks; The risk of premature optimization; Running time complexity; Constant time
  • O(1); Linear time
  • O(n); Logarithmic time
  • O(log n); Linearithmic time
  • O(nlog n); Factorial time
  • O(n!); Quadratic time
  • O(n^); Profiling best practices.
  • Build a regression-test suiteMind your code; Be patient; Gather as much data as you can; Preprocess your data; Visualize your data; Summary; Chapter 2: The Profilers; Getting to know our new best friends: the profilers; cProfile; A note about limitations; The API provided; The Stats class; Profiling examples; Fibonacci again; Tweet stats; line_profiler; kernprof; Some things to consider about kernprof; Profiling examples; Back to Fibonacci; Inverted index; Summary; Chapter 3: Going Visual: GUIs to Help Understand Profiler Output; KCacheGrind
  • pyprof2calltree; Installation; Usage.
  • A profiling example
  • TweetStatsA profiling example
  • Inverted Index; RunSnakeRun; Installation; Usage; Profiling examples
  • the lowest common multiplier; A profiling example
  • search using the inverted index; Summary; Chapter 4: Optimize Everything; Memoization / lookup tables; Performing a lookup on a list or linked list; Simple lookup on a dictionary; Binary search; Use cases for lookup tables; Usage of default arguments; List comprehension and generators; ctypes; Loading your own custom C library; Loading a system library; String concatenation; Other tips and tricks; Summary.
  • Chapter 5: Multithreading versus MultiprocessingParallelism versus concurrency; Multithreading; Threads; Multiprocessing; Multiprocessing with Python; Summary; Chapter 6: Generic Optimization Options; PyPy; Installing PyPy; A Just-in-time compiler; Sandboxing; Optimizing for the JIT; Think of functions; Consider using cStringIO to concatenate strings; Actions that disable the JIT; Code sample; Cython; Installing Cython; Building a Cython module; Calling C functions; Solving naming conflicts; Defining types; Defining types during function definitions; A Cython example; When to define a type.
  • LimitationsGenerator expressions; Comparison of char* literals; Tuples as function arguments; Stack frames; How to choose the right option; When to go with Cython; When to go with PyPy; Summary; Chapter 7: Lightning Fast Number Crunching with Numba, Parakeet, and pandas; Numba; Installation; Using Numba; Numba's code generation; Running your code on the GPU; The pandas tool; Installing pandas; Using pandas for data analysis; Parakeet; Installing Parakeet; How does Parakeet work?; Summary; Chapter 8: Putting It All into Practice; The problem to solve; Getting data from the Web.