Faster Python Programs through Optimization (Mike Müller)

Although Python programs may be slow for certain types of tasks, there are

many different ways to improve performance. This tutorial will introduce

optimization strategies and demonstrate techniques to implement them.

Another of the objectives of this course is to give participants the ability

to decide what might be the optimal solution for a certain performance problem. Participants are strongly recommended to bring laptops because all techniques

are introduced with examples and exercises.

Intended Audience

Python programmers with intermediate knowledge.

Class Outline

  • How Fast is Fast Enough?

  • Optimization Guidelines

    • Premature optimization
    • Optimization rules
    • Seven steps for incremental optimization
  • Optimization strategy

    • Measuring in stones
    • Profiling CPU usage
    • Profiling memory usage
  • Algorithms and Anti-patterns

    • String Concatenation
    • List and Generator Comprehensions
    • The Right Data Structure
    • Caching
  • The Example

  • Testing Speed

  • Pure Python

  • Meet Psyco, the JIT

  • Numpy for Numeric Arrays

  • Using multiple CPUs with pyprocessing/multiprocessing

  • Combination of optimization strategies

  • Results of Different Example Implementations

Requirements

All participants should bring laptops with Linux, Windows, or Mac OS.

Python 2.6, 2.5, or Python 2.4 need to be installed as well as an

editor or IDE.

The following third-party packages are needed:

Diamond

  • Google - Diamond

Platinum

  • CCP Games - Platinum

Gold

  • Walt Disney Animation Studios - Gold
  • Net-ng - Gold
  • Socialserve.com - Gold
  • Activestate - Gold
  • White Oak Technologies Inc - Gold
  • Canonical - Gold
  • Microsoft - Gold
  • Sauce Labs - Gold
  • The Rackspace Cloud - Gold
  • ESRI - Gold
  • Oracle - Gold

Silver

  • Enthought - Silver
  • Wingware - Silver
  • Imaginary Landscape - Silver
  • Emma Email Marketing - Silver
  • Visual Numerics, Inc - Silver
  • HiiDef - Silver
  • Breadpig - Silver
  • Accense - Silver
  • Tummy - Silver
  • Zeomega - Silver

Vendor I

  • O'Reilly - Vendor I

Media

  • Linux Journal - Media
  • LinuxPro Magazine - Media
  • Ubuntu User - Media
  • CODE Magazine - Media
  • Startup Riot - Media
  • The Bit Source - Media