Emin's Page

Erasure Correcting Codes In Python


py_ecc version 1.4 (requires python 2.2 or better)

This page contains Python source code for Reed-Solomon codes (a type of erasure correcting code), finite field arithmetic, and generic matrix operations. Erasure correcting codes let you divide up a piece of information (e.g., a file or a packet) into n pieces of which k are needed for recovery. By storing/sending these n pieces in/through separate disks/channels the file/packet can be recovered provided at least k out of n pieces are received correctly. See comments in the source code for a more detailed discussion.

One of my goals in writing this code was to provide a clear, easy to understand reference for other people who want to implement linear error correcting codes or otherwise use finite fields. Consequently the code contains extensive documentation and a number of detailed examples and tests.

A brief description of each file follows, look at the individual files for documentation and detailed examples.

  • ffield.py A stand alone package for finite field operations in Python.
  • genericmatrix.py A stand alone package for matrix operations over an arbitrary field (e.g. a finite field, the field of real numbers, the field of complex numbers). Some highlights include Gaussian elimination, determinants, inverses, and LU/LUP decompositions.
  • rs_code.py A Reed-Solomon encoder and (erasure) decoder built using ffield.py and genericmatrix.py.
  • file_ecc.py An application which provides erasure correction for files (e.g. if you want to write your own software RAID for your backups).
  • CHANGELOG.

If you prefer, you can download everything as a tarball:

You can find an extensive list of other error correcting algorithms at the The Error Correcting Code Page.