Mastering Python 3 I/O

Copyright (C) 2010
David M. Beazley
http://www.dabeaz.com

Presented at PyCon'10, February 17, 2010, Atlanta, Georgia.

Introduction

As most Python programmers know, Python 3 breaks backwards compatibility with Python 2 both in syntax and new semantics of built-in operations. One of the most radical changes concerns the ground-up redesign of the I/O system. This tutorial aims to take a tour of the new I/O stack. Topics include text processing, binary data handling, system interfaces, io library module, memory views, and porting advice.

Support Files

The following file contains some supporting data files that are used in some of the code samples. There are also some code fragments to experiment with things.

This download also includes all of the code samples that follow below.

Code Samples

Here are various code samples that you can use to try things things out during the course. They're presented in the same order as presentation slides.

Preliminaries:

Part 1 : Introducting Python 3

Part 2 : Working with Text

Part 3 : Binary Data Handling

Part 4 : System Interfaces

No files

Part 5 : The io module

These files have a few simple performance tests for comparing different file modes, encodings, etc. You should try these under both Python 2 and 3.

Part 6 : Standard Library Issues

No files.

Part 7 : Memory Views and I/O

Feedback

I'm always looking for ways to improve presentation materials and examples. Send your ideas to dave@dabeaz.com.