Sessions at PyCon US 2012 in Santa Clara Convention Center

Your current filters are…

Wednesday 7th March 2012

  • Bayesian statistics made (as) simple (as possible)

    by Allen Downey

    This tutorial is an introduction to Bayesian statistics using Python. My goal is to help participants understand the concepts and solve real problems. We will use material from my book, Think Stats: Probability and Statistics for Programmers (O’Reilly Media).

    Bayesian statistical methods are becoming more common and more important, but there are not many resources to help beginners get started. People who know Python can use their programming skills to get a head start.

    I will present simple programs that demonstrate the concepts of Bayesian statistics, and apply them to a range of example problems. Participants will work hands-on with example code and practice on example problems.

    Students should have at least basic level Python and basic statistics. If you learned about Bayes’s Theorem and probability distributions at some time, that’s enough, even if you don’t remember it! Students should be comfortable with logarithms and plotting data on a log scale.

    Students should bring a laptop with Python 2.x and matplotlib. You can work in any environment; you just need to be able to download a Python program and run it.

    Outline:

    • Bayes’s theorem.
    • Representing probability distributions.
    • Bayesian estimation.
    • Biased coins and student test scores.
    • Censored data.
    • The locomotive / German tank problem.
    • Hierarchical models and the hidden species problem.

    At 9:00am to 12:20pm, Wednesday 7th March

    In D2, Santa Clara Convention Center

    Coverage video

  • Faster Python Programs through Optimization

    by Mike Müller

    This tutorial provides an overview of techniques to improve the performance of Python programs. The focus is on concepts such as profiling, difference of data structures and algorithms as well as a selection of tools and libraries that help to speed up Python.

    Objective

    This tutorial provides an overview of techniques to improve the performance of Python programs. The focus is on concepts such as profiling, diffrence of data structures and algorithms as well as a selection of tools an libraries that help to speed up Python.

    Intended Audience

    Python programmers who would like concepts to improve performance.

    Audience Level

    Programmers with good Python knowledge.

    Prerequisites

    Please bring your laptop with the operating system of your choice (Linux, Mac OS X, Windows). In addition to Python 2.6 or 2.7, we need:

    Method

    This is a hands-on course. Students are strongly encouraged to work along with the trainer at the interactive prompt. There will be exercises the students need to do on their own. Experience shows that this active involvement is essential for an effective learning.

    Outline

    • How fast is fast enough? (10 min)
    • Optimization guidelines (10 min)
    • Premature optimization
    • Optimization rules
    • Seven steps for incremental optimization
    • Optimization strategy (30 min)
    • Measuring in stones
    • Profiling CPU usage
    • Profiling memory usage
    • Algorithms and Anti-patterns (40 min)
    • String concatenation
    • List and generator comprehensions
    • The right data structure
    • Caching
    • The example (5 min)
    • Testing speed (5 min)
    • Pure Python (15 min)
    • Meet Psyco, the JIT (5 min)
    • Using PyPy (15 min)
    • NumPy for numeric arrays (10 min)
    • Using multiple CPUs with multiprocessing (20 min)
    • Combination of optimization strategies (10 min)
    • Results of different example implementations (5 min)

    At 9:00am to 12:20pm, Wednesday 7th March

    In D1, Santa Clara Convention Center

    Coverage video

  • Hands-on Beginning Python

    by Matt Harrison

    We're going to mesh TDD, a desire to learn Python and Brazilian BBQ. Bring your laptop (having Python 2.x installed (will note 3.x differences)). This is hands on! You will program! It is assumed that you know how to program but perhaps not in Python. You start hungry and leave stuffed. We assume you know nothing and will stuff you with enough Python to be dangerous.

    The tutorial works like this: There's a short presentation. A short testcase for you to complete. Rinse/repeat until we run out of time. Hopefully you'll walk away from this tutorial knowing how to write Python programs.

    Course will cover:

    • REPL
    • Types
    • Mutable/Immutable
    • Getting help
    • Lists
    • Dictionaries
    • Functions
    • Whitespace
    • Conditionals & booleans
    • Iteration
    • Slicing
    • I/O
    • Classes
    • Exceptions
    • Packaging and layout

    There are short testcases to allow participants to practice concepts.

    All participants will receive an ebook modeled on the tutorial, slides, a handout and assignments, as well as prizes for completion of assignments.

    At 9:00am to 12:20pm, Wednesday 7th March

    In F1, Santa Clara Convention Center

  • Introduction to Django

    by Chander Ganesan

    The Django framework is a fast, flexible, easy to learn, and easy to use framework for designing and deploying web sites and services using Python. In this session, we'll cover the fundamentals of development with Django, generate a Django data model, and put together a simple web site using the framework.

    • Detailed Tutorial Outline
    • Django Overview and Basic Introduction
    • Downloading & Installing Django
    • Creating a new project
    • Choosing a database
    • Creating a new application
    • Installing & Using Django contrib applications
    • Overview of Django flow (i.e., URLconf expression, view function, HTTPResponse object, etc.)
    • Generating Simple Django Views
    • Configuring a URLConf for basic views
    • Creating Django Templates (template syntax, common filters and tags, loops, etc)
    • Creating & using Template Context objects
    • Introduction to Django Models
    • Defining basic Django models
    • Understanding basic model fields & options
    • Generating & Reviewing Model SQL
    • Adding data to a model
    • Simple data retrieval using models
    • Working with QuerySets (filters, slicing, ordering, common methods)
    • Overview of Q objects)
    • Using the Admin interface
    • Using Generic views
    • Access control with sessions & users

    At 9:00am to 12:20pm, Wednesday 7th March

    In H3, Santa Clara Convention Center

  • Introduction to Event Driven Programming Using Twisted

    by Jean-Paul Calderone

    This tutorial introduces programmers with a basic Python skills to the concepts and techniques of event driven programming. The focus is on understanding an event loop and handling the events related to TCP connections. Twisted is introduced as a re-usable event loop implementation and the abstract concepts of event driven programming are related to specific uses of the Twisted library.

    • What is event driven programming
    • What is it an alternative to
    • What are its advantages
    • How does an event loop work
    • Build one step by step to demonstrate
    • Demonstrate a server which can handle many clients
    • Demonstrate a client which can run in the same event loop
    • Demonstrate timed events in the event loop
    • How are event handlers connected to form a program
    • Callback functions
    • Deferreds
    • Generator tricks - inlineCallbacks
    • Coroutines - stackless, corotwine
    • More

    At 9:00am to 12:20pm, Wednesday 7th March

    In D3, Santa Clara Convention Center

    Coverage slide deck

  • IPython in-depth: high-productivity interactive and parallel python

    by Brian E. Granger, Min Ragan-Kelley and Fernando Pérez

    IPython provides tools for interactive and parallel computing that are widely used in scientific computing, but can benefit any Python developer. We will show how to use IPython in different ways, as: an interactive shell, an embedded shell, a graphical console, a network-aware VM in GUIs, a web-based notebook with code, graphics and rich HTML, and a high-level framework for parallel computing.

    IPython started as a better interactive Python interpreter in 2001, but over the last decade it has grown into a rich and powerful set of interlocking tools aimed at maximizing developer productivity with Python while using the language interactively.

    Today, IPython consists of a kernel that executes the user code and controls the user's namespace, and a collection of tools to control this kernel either in-process or out-of-process thanks to a well-specified communications protocol implemented over ZeroMQ. The kernel can do much more than execute user code, including introspection of objects in the user's namespace, detailed error reporting with rich tracebacks, history logging of inputs and outputs with an SQLite backend, a user-extensible system of commands for interactive control that don't collide with user variables, and much more.
    Our communications architecture allows these same features to be accessed via a variety of clients, each providing unique functionality tuned to a specific use case. We expose a number of directly usable applications:

    An interactive, terminal-based shell with many capabilities far beyond the default Python interactive interpreter (this is the default application opened by the ipython command that most users are familiar with).

    A Qt console that provides the look and feel of a terminal, but adds support for inline figures, graphical calltips, a persistent session that can survive crashes (even segfaults) of the kernel process, and more. A user-based review of some of these features can be found here.

    A web-based notebook that can execute code and also contain rich text and figures, mathematical equations and arbitrary HTML. This notebook controls the same kernel as the other two applications, but instead of offering a linear, terminal-like workflow, it presents a document-like view with cells where code is executed but that can be edited in-place, reordered, mixed with explanatory text and figures, etc. This model is a kind of literate programming environment popular in scientific computing and pioneered by the Mathematica system, that allows for the creation of rich documents that combine computational experimentation and results with other explanatory elements. A detailed review of this system can be found here.

    A high-performance, low-latency system for parallel computing that supports the control of a cluster of IPython engines communicating over ZeroMQ, with optimizations that minimize unnecessary copying of large objects (especially numpy arrays). These engines can be controlled interactively while developing and doing exploratory work, or can run in batch mode either on a local machine or in a large cluster/supercomputing environment via a batch scheduler.

    In this hands-on, in-depth tutorial, we will briefly describe IPython's architecture and will then show how to use and configure each of the above components. We will also discuss how to use the underlying IPython libraries in your own application to provide interactive control.

    An outline of the tutorial follows:

    • Introductory description of the project and architecture.
    • IPython basics: the magic command system, shell aliases, full shell access, the history system, variable caching, object introspection tools.
    • Development workflow: combining the interpreter session with python files via the %run command.
    • Effective use of IPython at the command-line for typical development tasks: timing, profiling, debugging.
    • Embedding IPython in terminal applications.
    • The IPython Qt console: unique features beyond the terminal.
    • Embedding an IPython kernel in a GUI app to expose network-based interactive control.
    • Configuring IPython: the profile and configuration system for multiple applications.
    • The IPython notebook: interactive usage of the application, the IPython display protocol, defining custom display methods for your own objects, generating HTML and PDF output.
    • Parallelism with IPython: basic architecture, interactive control of a cluster, standalone execution of applications, integration with MPI, blocking and asynchronous parallelism, execution in batch-controlled environments, IPython engines in the cloud (illustrated with Amazon EC2 instances).

    A short listing of other features not covered in this tutorial, as guidance for users to later learn about on their own.

    For full details about IPython including documentation, previous presentations and videos of talks, please see the project website.

    At 9:00am to 12:20pm, Wednesday 7th March

    In F2, Santa Clara Convention Center

  • SQL for Python Developers

    by Brandon Rhodes

    Relational databases are often the bread-and-butter of large-scale data storage, yet they are often poorly understood by Python programmers. Organizations even split programmers into SQL and front-end teams, each of which jealously guards its turf. These tutorials will take what you already know about Python programming, and advance into a new realm: SQL programming and database design.

    The class will consist of six 25-minute lessons, each of which features a 10-minute lecture, 10 minutes of interesting exercises, and a 5-minute wrap-up in which the instructor recaps the exercises by giving his own answers. The focus will be on keeping things simple so that each building block is grasped clearly. The six lessons will be laid out something like this:

    1. Tables, INSERT, and SELECT.

    • Create a simple sqlite3 table with the DB-API interface provided by the Python Standard Library.
    • Use INSERT to fill the table with data.
    • Concatenate INSERT statements to increase the speed and reduce the number of database round-trips required during a bulk data load.
    • Read back table rows with SELECT.
    • Add dynamic expressions to the rows returned by SELECT.
    • Quote values correct to avoid SQL injection attacks.
    • Avoid “gotchya” differences between Python and SQL data types, with particular attention to Unicode, date-times, and the behavior of NULL verses None.

    2. WHERE and the importance of being indexed.

    • Run quick performance checks that demonstrate that WHERE usually requires the entire table to be read into memory and scanned.
    • Add a simple index to shortcut specific WHERE clauses and return their results more quickly.
    • Check whether an index is being used, and learn several reasons why apparently useful indexes get ignored by the database.
    • Add aggregate indexes that yield performance increases for very specific WHERE clauses.
    • Investigate how our data distrubtion — for example, whether a particular column has thousands of different values, or merely thousands of instances of a handful of values — can impact the wisdom and performance of various query plans.

    3. FOREIGN KEY and JOIN

    • Use a foreign key to relate rows in one table with rows in another.
    • Add JOIN clauses to a SELECT statement to assemble query-result rows that are built from pieces of several tables.
    • Diagnose performance problems with JOIN by observing the cost of full N×M scans that compare every row from one table with every row from another.
    • Think about the indexes that a query plan could take advantage of behind the scenes.
    • Create indexes that let the database take shortcuts when doing common JOINs.

    4. Post-processing.

    • Use ORDER BY to control the rows which are returned first by a given query.
    • Combine OFFSET and LIMIT to return "paged" results suitable for displaying on a limited display, like a web page or GUI window
    • Observe how indexes affect the performance of ORDER BY / LIMIT.
    • Use GROUP BY to support aggregate operations such as sums, averages, maxima, and minima.
    • Filter aggregate results with the HAVING clause.

    The exercises will present small Python scripts that post-process data, and ask students to write the equivalent GROUP BY / HAVING expressions to remove the need for the Python post-processing.

    5. Modifying tables.

    • Write WHERE clauses for UPDATE and DELETE using the same patterns already learned for SELECT.
    • Use transactions in combinations with UPDATE and DELETE to prevent inconsistent database states from becoming visible to other clients.

    6. ORMs, Objects, and Tables.

    • Create tables of objects using the SQLAlchemy declarative schema in combination with classes.
    • Understand the main differences between SQLAlchemy and the Django ORM, including the idea of explicit saves versus a unit-of-work pattern.
    • See how ORM query syntaxes mix down to SQL statements.
    • Determine when an ORM will be helpful, versus when straight SQL might be a better solution for a particular problem.

    Of course, mastery of these topics cannot be conveyed in a single three-hour course! The tutorial will have succeeded if students learn the main moving parts that are involved in a relationally-backed Python application, if they have gotten some practice with SQL and the kind of tasks that it seeks to simplify, and if they have a foundation upon which to build when they are next faced with writing or modifying Python code that interfaces with a SQL database.

    At 9:00am to 12:20pm, Wednesday 7th March

    In H2, Santa Clara Convention Center

    Coverage video

  • Writing a Pyramid application

    by Carlos de la Guardia

    Pyramid is the web framework at the core of the Pylons Project. It's a "pay only for what you eat" framework. You can get started easily and learn new concepts as you go, and only if you need them. It's simple, well tested, well documented, and fast. This course will present Pyramid and lead you through the creation of a an application as the concepts from the framework are introduced.

    Pyramid is the web framework at the core of the Pylons Project. It’s a “pay only for what you eat” framework. You can get started easily and learn new concepts as you go, and only if you need them. It’s simple, well tested, well documented, and fast.

    Though it’s in part inspired by Zope and uses concepts and software that may be familiar to Zope programmers, no prior Zope experience is required to use it. Also, unlike Zope, you don’t need to understand many concepts and technologies fully before you can be truly productive.

    Pyramid is also inspired by Django and Pylons. It tries to learn valuable lessons from things that have gone well with different web frameworks and give the user great flexibility in applying them.

    This course will present Pyramid and lead you through the creation of a an application as the concepts from the framework are introduced. The extensive Pyramid documentation will be used as “text book”.

    Proposed outline:

    • Installation
    • Scaffolds
    • Persistence options
    • URL dispatch
    • Views
    • View configuration
    • Renderers
    • Static views
    • Security
    • Declarative configuration
    • Testing
    • Deployment

    At 9:00am to 12:20pm, Wednesday 7th March

    In H1, Santa Clara Convention Center

    Coverage video

  • Data analysis in Python with pandas

    by Wes McKinney

    The tutorial will give a hands-on introduction to manipulating and analyzing large and small structured data sets in Python using the pandas library. While the focus will be on learning the nuts and bolts of the library's features, I also aim to demonstrate a different way of thinking regarding structuring data in memory for manipulation and analysis.

    The tutorial will teach the mechanics of the most important features of pandas. It will be focused on the nuts and bolts of the two main data structures, Series (1D) and DataFrame (2D), as they relate to a variety of common data handling problems in Python. The tutorial will be supplemented by a collection of scripts and example data sets for the users to run while following along with the material. As such a significant part of the tutorial will be spend doing interactive data exploration and working examples from within the IPython console.

    The tutorial will also teach participants best practices for structuring data in memory and the do's and don'ts of high performance computing with large data sets in Python. For participants who have never used IPython, this will also provide a gentle introduction to interactive scientific computing with IPython.

    At 1:20pm to 4:40pm, Wednesday 7th March

    In D2, Santa Clara Convention Center

    Coverage video

  • Django in Depth

    by James Bennett

    A tutorial that goes beyond all other Django tutorials; we'll dive deep into the guts of the framework, and learn how each commonly-used component -- ORM, templates, HTTP handling, views and the admin -- work from the bottom up, covering both public and internal APIs in excruciating detail.

    At 1:20pm to 4:40pm, Wednesday 7th March

    In D1, Santa Clara Convention Center

  • Graph Analysis from the Ground Up

    by Van Lindberg

    Graphs are a fundamental datatype - but typical developers don't get as much exposure to using and working with graphs as with other datatypes like tables and queues. This is a from-the-ground up working session; by the end, attendees should have the tools and experience to model and analyze problems with graphs.

    This tutorial is intended to bring somebody with Python experience but limited or no experience using graph-based algorithms to a place where they:

    • Understand the basics of graph theory and why it can be helpful;
    • Are familiar with the available tools for dealing with graphs;
    • Recognize how to model a problem in terms of a graph; and
    • Have a first hands-on experience applying the theory and the tools to solve an interesting real-world problem.

    To do this, the tutorial is divided into four sections, each corresponding to one of the objectives above. Each portion will have a hands-on exercise pertaining to the exact subject, with part 4 as a crowning workshop bringing together various skills and points raised throughout the session; after having a few minutes to work on their own code and ask questions, the class as a whole will walk through a solution.

    At 1:20pm to 4:40pm, Wednesday 7th March

    In D3, Santa Clara Convention Center

  • Hands-on Intermediate Python

    by Matt Harrison

    Are you new to Python and want to learn how to step it up to the next level? Have you wondered about functional programming, closures, decorators, context managers, generators or list comprehensions and when you should use them and how to test them? This hands-on tutorial will cover these intermediate subjects in detail, by explaining the theory behind them then walking through examples.

    Tutorial will be in the the form of short lecture, short assignment to practice the concepts.

    Attendees should come with a laptop and Python 2.x (3.x differences will be noted).

    Tutorial will cover:

    • Testing (unittest and doctest)
    • Functional Programming
    • Functions
    • Closures
    • Decorators
    • Class decorators
    • Properties
    • Context Managers
    • List comprehensions
    • Iterator pattern
    • Generators

    Materials include an ebook covering the material, slides, handout and assignment code. Prizes to be awarded for completion of assignment.

    At 1:20pm to 4:40pm, Wednesday 7th March

    In F1, Santa Clara Convention Center

  • How to get the most out of your PyPy

    by Armin Rigo, Alex Gaynor and Maciej Fijalkowski

    For many applications PyPy can provide performance benefits right out of the box. However, little details can push your application to perform much better. In this tutorial we'll give you insights on how to push pypy to it's limites. We'll focus on understanding the performance characteristics of PyPy, and learning the analysis tools in order to maximize your applications performance.

    We aim to teach people how to use performance tools available for PyPy as well as to understand PyPy's performance characteristics. We'll explain how different parts of PyPy interact (JIT, the garbage collector, the virtual machine runtime) and how to measure which part is eating your time. We'll give you a tour with jitviewer which is a crucial tool for understanding how your Python got compiled to assembler and whether it's performing well. We also plan to show potential pitfalls and usage patterns in the Python language that perform better or worse in the case of PyPy.

    We'll also briefly mention how to get your application running on PyPy and how to avoid common pitfalls there, like reference counting or relying on C modules.

    This tutorial is intended for people familiar with Python who have performance problems, no previous experience with PyPy is needed. We ask people to come with their own problems and we'll provide some example ones. Attendees should have the latest version of PyPy preinstalled on their laptops.

    At 1:20pm to 4:40pm, Wednesday 7th March

    In H1, Santa Clara Convention Center

    Coverage video

  • MongoDB and Python

    by Rick Copeland and Bernie Hackett

    This intermediate-level class will teach you techniques using the popular NoSQL database MongoDB, its driver PyMongo, and the object-document mapper Ming to write maintainable, high-performance, and scalable applications. We will cover everything you need to become an effective Ming/MongoDB developer from basic PyMongo queries to high-level object-document mapping setups in Ming.

    The class will begin with a brief overview of MongoDB and its Python driver PyMongo. We will cover basic operations using PyMongo, including data manipulation, querying, and GridFS. Students will install MongoDB and PyMongo as part of this section.

    We will then describe the design philosophy and setup of Ming, a SQLAlchemy-inspired object-document mapper (ODM) for MongoDB developed at SourceForge.

    Next we will cover the base-level implementation of Ming, including schema design, the session and datastore, lazy migrations, data polymorphism, and GridFS support. We will also cover effective MongoDB index design, querying, and updating techniques, and how to use these with Ming. Students will install Ming as a part of this section, and have exercises covering schema design, lazy migrations, and GridFS.

    The final segment will cover the object-document mapper portion of Ming. We will cover the unit of work design pattern, object relations, ODM-level polymorphism, and how to drop down to the base layer (or even down to pymongo) when you really need to. This section will include exercises in designing your ODM model and effectively using the unit-of-work session.

    This talk targets Python 2.6-2.7 and MongoDB 2.0. Students should have Python 2.6 or 2.7 installed on their machines prior to the class and should be comfortable using virtualenv and pip or easy_install to install packages.

    At 1:20pm to 4:40pm, Wednesday 7th March

    In H2, Santa Clara Convention Center

    Coverage video note

  • The real-time web with co-routines

    by John Anderson

    Learn how to build fast and interactive web applications using a wsgi compliant web framework and co-routines. Utilizing Redis/ZeroMQ, Socket.IO, and GEvent you will learn how to build a responsive and concurrent web app while maintaining good test coverage.

    We will build a collaborative todo list system that will show you how to utilize Python, Redis/ZeroMQ, Socket.io, and GEvent for real-time communication.

    We will focus on the following topics:

    Using a wsgi framework to build a RESTful interface and hooking up socket.io to it.
    Using socketio and redis/zeromq for subscribing to named channels and communicating in real-time over websockets.
    Gevent
    Testing your real-time application
    Deployment and Monitoring
    A rough outline
    GEvent (30 min)

    Intro to GEvent and co-routines, what it is, how it works, the benefits of using it, and how simple it is to wrap your mind around a co-routine vs the callback methodology of threads.

    ZeroMQ / Redis (30 min)

    Intro to pub/sub, the communication model we'll use for our realtime communication and how to utilize ZeroMQ or Redis to achieve this.

    Socket.IO and Backbone.js (30 min)

    Discussion of Polling, Longpolling, Flash sockets, and web sockets and the benefits of each and how Socket.IO lets us not care. I will discuss how to get socket.io client side working with the server side.

    Testing (15 min)

    We will cover how to architect your co-routine based applications to make them easily testable and how to utilize mock to make things easier. We will cover the gotcha's of testing GEvent based code.

    Deployment (15 min)

    The final portion of the tutorial we discuss deployment and how to manage and monitor your WSGI server that is using GEvent patched libraries. This will cover basics on which webservers to use as well as exception handling.

    We leave 30minutes of leeway to further discussion in a certain area that the students are most interested in as well as for questions on things specific that they feel I may not have covered so far.

    I will provide the non-realtime code base for the application we will be working on and we will start from there and slowly add in support for the realtime communication as we discuss the technologies needed.

    Most introductions to the web with gevent just show a basic chat application which leaves a lot of questions about where to go next once you are building a real application and I hope to cover all of those in this tutorial.

    At 1:20pm to 4:40pm, Wednesday 7th March

    In F2, Santa Clara Convention Center

  • Web scraping: Reliably and efficiently pull data from pages that don't expect it

    by Asheesh Laroia

    Exciting information is trapped in web pages and behind HTML forms. In this tutorial, you'll learn how to parse those pages and when to apply advanced techniques that make scraping faster and more stable. We'll cover parallel downloading with Twisted, gevent, and others; analyzing sites behind SSL; driving JavaScript-y sites with Selenium; and evading common anti-scraping techniques.

    • Basics of parsing
    • The website is the API
    • HTML is a mess, but we can parse it anyway
    • Why regular expressions are a bad idea
    • Extracting information, using XPath, CSS selectors, and the BeautifulSoup API
    • Expect exceptions: How to handle errors
    • Basics of crawling
    • A quick review of HTTP
    • Why cookies are necessary for maintaining a session
    • How servers can track you
    • How to submit forms with mechanize
    • Debugging the web
    • Comparing FireBug and Chrome's DOM Inspector
    • The "Net" tab
    • Using a logging HTTP proxy to record traffic
    • Counter-measures, and how to circumvent them
    • JavaScript
    • Hidden form fields (e.g., Django CSRF)
    • CAPTCHAs
    • IP address limitations
    • How to cover your scraping code with tests
    • Why you should store snapshotted pages
    • Using mock objects to avoid network I/O
    • Using a fake getPage for Twisted
    • Parallelism
    • A quick tour of different models:
    • Twisted
    • gevent
    • celery
    • Handling JavaScript
    • Automating a full web browser with Selenium RC
    • Running JavaScript within Python using python-spidermonkey
    • Conclusion
    • Use your power for good, not evil.
    • Q&A

    At 1:20pm to 4:40pm, Wednesday 7th March

    In H3, Santa Clara Convention Center

    Coverage video

Thursday 8th March 2012

  • Advanced Python I

    by Raymond Hettinger

    Have your Python skills have hit a plateau? Come learn from Python core developer and consultant Raymond Hettinger about the tips and tricks needed to move up to the next level.

    This tutorial will work through a series of real-world examples, showing how an understanding of the tools built into the Python interpreter or included in the standard library can be combined to solve difficult problems clearly and Pythonically. We will also discuss when and how to reach beyond the standard library when needed to address difficult algorithmic and optimization problems. This can be taken as a stand-alone session or in conjunction with the second session; the two sessions will be complementary.

    At 9:00am to 12:20pm, Thursday 8th March

    In D1, Santa Clara Convention Center

    Coverage note

  • Documenting Your Project With Sphinx

    by Brandon Rhodes

    Python projects can succeed or fail because of their documentation. Thanks to Sphinx, Python now has a “documentation framework” with indexing, syntax highlighting, and integration with your code. Students will be given a small undocumented Python package, and during the exercises they will give the package a tutorial and reference manual. Plus: deployment and theming!

    Python projects can succeed or fail based on their documentation. Thanks to Sphinx, Python now has a "documentation framework" that provides convenient indexing and automatic syntax highlighting, and can also integrate your documentation with your code (your documentation can be run as a test, and your class and function docstrings can become your reference documentation). Students will be given an undocumented sample Python package, and be lead through exercises that result, by the end of the tutorial, in their giving the package a full tutorial and reference manual. Deployment and theming will also be taught.

    Besides a 15-minute introduction and 15 minutes for questions and discussion at the end, the tutorial will be organized in six 25-minute sessions which each involve a short lecture and then an interactive exercise that asks the students to apply what they have just learned. Here are the major topics covered by each of the six sessions:

    • The reStructuredText markup language and its syntax; the standard doctools; and the two different conventions that Sphinx can support for laying projects out as directories and files.
    • The Sphinx documentation build process on both Unix and Windows; how to arrange your project documentation in a way that will make sense to novice, experienced, and expert users alike; and how Sphinx supports connections between different pages of documentation.
    • Running code examples in the documentation as doctests; the pros and cons of pulling docstrings from the code as API documentation (and how to do it if it proves necessary); and including non-doctest full code listings in the documentation.
    • Referencing headings in the same document; cross-referencing between documents; making class and method names automatically link to their entry in the API documentation; and how to make code objects appear in the index.
    • Theming with custom HTML and CSS, for students who happen to know web design; plugging in pre-made Sphinx themes; and how to integrate Sphinx into an entire web site for their product.
    • Shipping documentation with your package on PyPI; installing it readthedocs.org; making sure that documentation gets included with a binary install; using a version control source browser to view documentation directly in their project trunk; and deploying Sphinx to a web site.

    The Sphinx approach will be linked to other successful documentation systems in our computing heritage, most notably in the practices it shares in common with the Unix Documenter's Workbench (DWB) of the 1970s.

    At 9:00am to 12:20pm, Thursday 8th March

    In H2, Santa Clara Convention Center

    Coverage video

  • High Performance Python I

    by Ian Ozsvald

    At EuroPython 2011 I ran a very hands-on tutorial for High Performance Python techniques. This updated tutorial will cover profiling, PyPy, Cython, numpy, NumExpr, ShedSkin, multiprocessing, ParallelPython and pyCUDA. Here's a 55 page PDF write-up of the EuroPython material: http://ianozsvald.com/2011/07/25...

    At EuroPython 2011 I ran a very hands-on tutorial for High Performance Python techniques. This updated tutorial will cover:

    • profiling with cProfile, run_snake and line_profiler
    • PyPy
    • Cython
    • numpy with and without vectors
    • NumExpr
    • ShedSkin Py->C++ compiler
    • multiprocessing for multi-core
    • ParallelPython for multi-machine
    • pyCUDA demos

    I plan to expand the original material and to maybe also cover other tools like execnet and PyPy-numpy.

    At 9:00am to 12:20pm, Thursday 8th March

    In D2, Santa Clara Convention Center

  • Introduction to Game Development

    by Richard Jones and Katie Cunningham

    This tutorial will walk the attendees from some introductory game development theory (what makes a good game) and through development of a simple game (how to make a good game) with time left over for some experimentation and exploration of different types of games.

    The tutorial will start with Katie Cunningham giving an introduction to video games, covering the basic components of a game, and some general game genres. Some basic tropes in modern games will be explored, as well as pitfalls to avoid in making a game for a today’s audience. Genres will be paired with inexpensive/free examples that can be explored by the tutorial attendees later.

    The baton will then pass to Richard Jones who will walk through the practicalities of building a simple video game from scratch, starting with presenting one approach to structuring the game code to keep it sane. He will talk about what libraries are available and then focus on the facilities present in the library used in the tutorial.

    We will then walk through the development of a simple game during which the attendees will code the game. Once the game is developed we will talk about potential further development that possibilities and use the remaining tutorial time to encourage and assist attendees in their efforts to do so.

    The game developed will cover the key game-writing skills of controlling what appears on the screen (including animation), loading resources, handling user input and simulating the environment within the game.

    Participants should be familiar with Python, and must have pygame installed. We will not have time to deal with installation and compatibility issues so participants must check their laptops can run pygame applications.

    At 9:00am to 12:20pm, Thursday 8th March

    In H3, Santa Clara Convention Center

    Coverage video

  • Optimize Performance and Scalability with Parallelism and Concurrency

    by Robert Hancock

    From how the operating system handles your requests through design principles on how to use concurrency and parallelism to optimize your program's performance and scalability. We will cover processes, threads, generators, coroutines, non-blocking IO, and the gevent library.

    How processes, threads, coroutines, and non-blocking IO work from the operating system through code implementation and design principles to optimize Python programs. The difference between parallelism and concurrency and when to use each.

    The premise is that to make an informed decision you need to know what is happening under the hood. Once you understand the low level functionality, you can make the correct decision in the design phase.

    The emphasis is on practical application to solve real world problems.

    Outline

    • How the operating system handles traps and interrupts
    • Scheduling
    • Processes
    • Threads
    • The GIL
    • Generators
    • What is a coroutine?
    • What is a Python coroutine?
    • Blocking/Non-blocking I/O.
    • Parallelism versus Concurrency
    • How do these work with CPython, Pypy, and Stackless
    • Greenlets and libevent (gevent)
    • Design principles
    • Example networked application
    • Performance results
    • What are other the other options?

    At 9:00am to 12:20pm, Thursday 8th March

    In F2, Santa Clara Convention Center

  • Plotting with matplotlib

    by Mike Müller

    When it comes to plotting with Python many people think about matplotlib. It is widely used and provides a simple interface for creating a wide variety of plots from very simple diagrams to sophisticated animations. This tutorial is a hands-on introduction that teaches the basics of matplotlib. Students will learn how to create publication-ready plots with just a few lines of Python.

    Target Audience

    This tutorial is for Python users who would like to create nice 2d plots with Python.

    Audience Level

    Students should have a working knowledge of Python. NumPy knowledge is helpful but not required.

    Prerequisites

    Please bring your laptop with the operating system of your choice (Linux, Mac OS X, Windows). In addition to Python 2.6 or 2.7, we need: - a current versions of matplotlib (http://matplotlib.sourceforge.net) - IPython (http://ipython.org) and - NumPy (http://numpy.scipy.org).

    Method

    This is a hands-on course. Students are strongly encouraged to work along with the trainer at the interactive prompt. There will be exercises the students need to do on their own. Experience shows that this active involvement is essential for an effective learning.

    Content

    The library matplotlib provides many different types of diagrams from within Python with only few lines of code. Examples are used to exercise the use of this library. The tutorial provides an overview how to create plots with matplotlib. IPython in combination with pylab from matplotlib provides an interactive environment for fast testing of ideas. We will be using this for most of the tutorial.

    With a simple plot we learn how to add axis labels, titles and a legend. The GUI offers zooming, panning, changing of plot sizes and other interactive ways to modify the plot. We will use Python to change properties of existing plots such as line colors, marker symbols, or line styles. There are several ways how to place text on plots. You will learn about the different coordinate systems relative to the plot, the canvas or the figure. Another topic are ticks, where to put them and how to format them to achieve publication-quality plots. The concepts of figures, subplots, and axes and how they relate to each other will be explained with examples.

    matplotlib offers many different types of plots. The tutorial introduces several of them with an example. A more advanced topic will be creating your own plot types. We will build a stacked plot type. Finally, we will create a small animation to explore the possibilities to visualize changes.

    Outline

    • Introduction (5 min)
    • IPython (5 min)
    • pylab (5 min)
    • Simple plots (20 min)
    • Properties (15 min)
    • Text (20 min)
    • Ticks (25 min)
    • Figures, subplots, and axes (25 min)
    • Other types of plots (10 min)
    • The class library (15 min)
    • Creating New Plot Types (20 min)
    • Animations (15 min)

    At 9:00am to 12:20pm, Thursday 8th March

    In H1, Santa Clara Convention Center

    Coverage video

  • Python Epiphanies

    by Stuart Williams

    This tutorial is for software developers who've been using Python with success for a while but are looking for a deeper understanding of the language. It demystifies a number of language features that are often misunderstood.

    In many ways Python is very similar to other programming languages. However, in a few sometimes subtle ways it is quite different, and many software developers new to Python, after their initial successes, hit a plateau and can't figure out how to get past it. Others don't hit or perceive a plateau, but still find some of Python's features a little mysterious. This tutorial will help deconstruct your incorrect assumptions about Python and pull away the mists of confusion.

    If in your use of Python you sometimes feel like an outsider, like you're missing the inside jokes, or like you have most of the puzzle pieces but they don't quite fit together yet, this may be a good tutorial for you.

    After completing this tutorial you'll have a deeper understanding of many Python features. Here are some of the topics we'll cover:

    • How namespaces really work, after which you'll understand:
    • most of the differences between variables in other languages and Python, including
    • why Python has neither pass-by-value nor pass-by-reference function call semantics, or why sometimes variables passed to a function can be changed by it, and sometimes they cannot.
    • Iterables, iterators, and the iterator protocol, including how to add it to a class
    • How generators can make your code easier to read and understand
    • Creating classes without a class statement in order to better understand how they work
    • Bound versus unbound methods and interesting uses of the former
    • How and why you might want to create or use a partial function
    • Other use-cases of functions as first-class citizens
    • Unpacking and packing arguments with * and ** on function call and definition

    Attendee Requirements

    Bring a laptop computer with a recent version of Python 2.7 or Python 3 installed.

    Prerequisites

    Intermediate ability in Python and little or no fear of iterators, generators, classes, methods, and how to call a function that's stored in a data structure.

    At 9:00am to 12:20pm, Thursday 8th March

    In F1, Santa Clara Convention Center

    Coverage video

  • Social Network Analysis with Python

    by Maksim Tsvetovat

    Social Network data permeates our world -- yet we often don't know what to do with it. In this tutorial, I will introduce both theory and practice of Social Network Analysis -- gathering, analyzing and visualizing data using Python and other open-source tools. I will walk the attendees through an entire project, from gathering and cleaning data to presenting results.

    SNA techniques are derived from sociological and social-psychological theories and take into account the whole network (or, in case of very large networks such as Twitter -- a large segment of the network). Thus, we may arrive at results that may seem counter-intuitive -- e.g. that Justin Bieber (7.5 mil. followers) and Lady Gaga (7.2 mil. followers) have relatively little actual influence despite their celebrity status -- while a middle-of-the-road blogger with 30K followers is able to generate tweets that "go viral" and result in millions of impressions.

    In this tutorial, we will conduct social network analysis of a real dataset, from gathering and cleaning data to analysis and visualization of results. We will use Python and a set of open-source libraries, including NetworkX, NumPy and Matplotlib.

    Outline:

    • Introduction. Why should we do this? What is the data like? Why is this different from other techniques? What can we learn?
    • Centralities: Degree, closeness, betweenness, PageRank, Klout Score
    • Beyond Klout Score: Finding communities of interest, finding clusters in networks
    • Information diffusion in networks -- how do things go viral?

    At 9:00am to 12:20pm, Thursday 8th March

    In D3, Santa Clara Convention Center

    Coverage video

  • Advanced Python II

    by Raymond Hettinger

    Have your Python skills have hit a plateau? Come learn from Python core developer and consultant Raymond Hettinger about the tips and tricks needed to move up to the next level.

    This tutorial will work through a series of real-world examples, showing how an understanding of the tools built into the Python interpreter or included in the standard library can be combined to solve difficult problems clearly and Pythonically. We will also discuss when and how to reach beyond the standard library when needed to address difficult algorithmic and optimization problems. This can be taken as a stand-alone session or in conjunction with the second session; the two sessions will be complementary.

    At 1:20pm to 4:40pm, Thursday 8th March

    In D1, Santa Clara Convention Center

  • Developing custom PyQt widgets and graphical interfaces efficiently.

    by Luis Artola

    Presents techniques and patterns for creating custom PyQt widgets easily. Focus is the separation of layout and logic to produce code that is easy to read and understand, and also inexpensive to maintain and evolve. Encourages and demonstrates the use of layout design applications, code generators and composition over inheritance. Based on PyQt4 but easily applicable to PySide as well.

    Many developers favor the creation of graphical user interfaces by hand-coding the layout of the interface elements. Most often than not, the resulting code is a highly cohesive mix of user interface and business logic that is not easy to maintain. Likewise, the development of custom widgets is often approached by subclassing top-level classes and overriding paint and event-handling methods. While this is the only alterantive for certain types of custom widgets, there is a big percentage that could be more easily created by composition of smaller widgets assembled together to work in as a unit.

    This tutorial aims to share the following with the audience:

    • Make a case for the benefits of using supporting tools for designing the layout portion of graphical user interfaces. In particular, the use of QtDesigner and code generators.
    • Present a pattern and project structure for creating PyQt widgets that can also be used inside QtDesigner.
    • Efficient use of composition over inheritance for assembling elaborate custom widgets more easily.

    All material is based on Python and PyQt4. Audience is expected to have working knowledge of PyQt. Or, at least proficiency developing application in Qt and C++.

    This tutorial is based on PyQt4 but concepts and techniques can be easily transferrable to PySide. Attendees require access to a computer with the following:

    • Qt 4.5.2 or later.
    • PyQt 4.5.4 or later.
    • sip 4.8.2 or later.
    • QtDesigner.
    • Python plugin for QtDesigner.
    • Python 2.5.x, 2.6.x or 2.7.x.

    An easy way to check whether the Python plugin is available or not is to select from QtDesigner's main menu: Help > About Plugins > Loaded Plugins, should show libpythonplugin.so. This is normally installed automatically by the Qt installer.

    At 1:20pm to 4:40pm, Thursday 8th March

    In H1, Santa Clara Convention Center

  • DevOps for Python: Doing More With Less

    by Noah Kantrowitz

    The world of infrastructure as code is becoming far more pervasive and many Python developers are trying to find a way to get started. This class will get you up and running with Chef and Fabric to manage your systems be they in the cloud or under your desk.

    Students must have a laptop with the Chef gem and git installed. Install instructions will sent out before the class.

    Agenda

    • Devops and Chef philosophy
    • Chef basics
    • Basic resources
    • Data bags
    • Environments
    • Intro to Ruby for Chef
    • Fabric

    At 1:20pm to 4:40pm, Thursday 8th March

    In F2, Santa Clara Convention Center

    Coverage video

  • High Performance Python II

    by Travis Oliphant

    In this tutorial, I will cover how to write very fast Python code for data analysis. I will briefly introduce NumPy and illustrate how fast code for Python is written in SciPy using tools like Fwrap / F2py and Cython. I will also describe interesting new approaches to creating fast code that is leading changes to NumPy on a fundamental level.

    In this tutorial, I will cover how to write very fast Python code for data analysis including making use of NumPy and using GPUs. I will largely focus on writing extensions to Python using hand-wrapping and Cython but will touch also on using tools like weave, Instant, ShedSkin and compare them to PyPy. I will also spend the last part of the tutorial on using GPUs with Python and discuss the performance trade-offs of the technology. This will be a high-level overview of the space with deep dives in Cython and GPUs

    Outline:

    • Brief Introduction to NumPy, SciPy and array-oriented computing with Python including exercises (1 hour)
    • Introduction to hand-wrapping and extending Python (1 hour)
    • Detailed description of Cython and how to use it to connect to machine-compiled code (1 hour)
    • Detailed description of GPUs and how to use them best with NumPy (45 minutes)
    • Summary and overview of using Python to write super fast code (15 minutes)

    At 1:20pm to 4:40pm, Thursday 8th March

    In D2, Santa Clara Convention Center

    Coverage video

  • Introduction to Interactive Predictive Analytics in Python with scikit-learn

    by Olivier Grisel

    The goal of this tutorial is to give the attendee a first experience of machine learning tools applied to practical software engineering tasks such as language detection of tweets, topic classification of web pages, sentiment analysis of customer products reviews and facial recognition in pictures from the web or from your own webcam.

    The demand for software engineers with Data Analytics and Machine Learning skills is rapidly growing and Python / Numpy is one of the best environments for quickly prototyping scalable data-centric applications or interactively exploring your data especially thanks to tools such as IPython and Matplotlib.

    scikit-learn is a very active open source project that implements a variety of state-of-the art machine learning algorithms. The goal of this project and tutorial is to take the algorithms out of the academic papers and make them work on a selection of real world tasks to unleash the value of your data.

    We will focus on providing hints to perform the right data preprocessing steps and on how to select algorithms and parameters suitable for the task at hand. We will also introduce tools and methodologies to measure the performance of the trained models as objectively as possible.

    At 1:20pm to 4:40pm, Thursday 8th March

    In F1, Santa Clara Convention Center

    Coverage video

  • Introduction to NLTK

    by Jacob Perkins

    Learn the basics of natural language processing with NLTK, the Natural Language ToolKit. First we'll cover tokenization, stemming and wordnet. Next we'll get into part-of-speech tagging, chunking & named entity recognition. Then we'll close with text classification and sentiment analysis. You'll walk out with new super-powers and an appreciation of the difficulties of analyzing human language.

    This tutorial will be a hands on approach to learning natural language processing using NLTK, the Natural Language ToolKit. We will cover everything from tokenizing sentences to phrase extraction, from splitting words to training your own text classifiers for sentiment analysis. Please come prepared with NLTK already installed so we can dive into the code & data immediately.

    Hour 1: Tokenization, Stemming & Corpora

    Tokenization & familiarity with corpus readers and models are required knowledge before you can get into the more interesting aspects of NLTK. This first hour will include:

    • an overview of modules & data
    • loading pickled models
    • sentence & word tokenization
    • stemming & lemmatization
    • an overview wordnet and other included corpora

    Hour 2: Part-of-Speech Tagging & Chunking/NER

    Using tokenization and a working knowledge of corpus readers & pickled models, we'll dive into part-of-speech tagging and chunking/NER, including:

    • using a part-of-speech tagger
    • an overview of tags and tagged corpora
    • training a custom tagger with nltk-trainer
    • using a chunker for phrase extraction and named entity recognition
    • an overview of chunked corpora
    • training a custom chunker with nltk-trainer

    Hour 3: Text Classification & Sentiment Analysis

    After using classifiers for training part-of-speech taggers and chunkers, this final hour will explain text classification in greater detail with:

    • an overview of classified corpora
    • text feature extraction
    • an overview of classification algorithms & when to use them
    • training a sentiment analysis classifier on movie reviews with nltk-trainer
    • using a classifier for sentiment analysis
    • hierarchical classification for sentiment analysis
    • binary vs multi-label classification

    Wrapping Up

    Now that you know how to use NLTK to process some of the included English corpora, we'll wrap up by covering:

    • non-english corpora included with NLTK
    • other Python libraries for NLP
    • custom corpus creation

    At 1:20pm to 4:40pm, Thursday 8th March

    In D3, Santa Clara Convention Center

Schedule incomplete?

Add a new session

Filter by Day

Filter by coverage

Filter by Topic

Filter by Venue

Filter by Space