creating/modifying sparse files on linux

Mike Meyer mwm at
Fri Aug 19 04:50:18 CEST 2005

"draghuram at" <draghuram at> writes:

> My goal is very simple. Have a mechanism to create sparse files and
> modify them by writing arbitratry ranges of bytes at arbitrary offsets.
> I did get the information I want (xrange instead of range, and a simple
> way to generate 1Mb string in memory). Thanks for pointing out about
> using "len" as variable. It is indeed silly.
> My only assumption from underlying OS/file system is that if I seek
> past end of file and write some data, it doesn't generate blocks for
> data in between. This is indeed true on Linux (I tested on ext3).

This better be true for anything claiming to be Unix. The results on
systems that break this aren't pretty.

Mike Meyer <mwm at>
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

More information about the Python-list mailing list