Re: creating/modifying sparse files on linux



[draghuram@xxxxxxxxx wrote]
>
> Hi,
>
> Is there any special support for sparse file handling in python? My
> initial search didn't bring up much (not a thorough search). I wrote
> the following pice of code:
>
> options.size = 6442450944
> options.ranges = ["4096,1024","30000,314572800"]
> fd = open("testfile", "w")
> fd.seek(options.size-1)
> fd.write("a")
> for drange in options.ranges:
> off = int(drange.split(",")[0])
> len = int(drange.split(",")[1])
> print "off =", off, " len =", len
> fd.seek(off)
> for x in range(len):
> fd.write("a")
>
> fd.close()
>
> This piece of code takes very long time and in fact I had to kill it as
> the linux system started doing lot of swapping. Am I doing something
> wrong here? Is there a better way to create/modify sparse files?

test_largefile.py in the Python test suite does this kind of thing and
doesn't take very long for me to run on Linux (SuSE 9.0 box).

Trent

--
Trent Mick
TrentM@xxxxxxxxxxxxxxx
.



Relevant Pages

  • Re: Komodo syntax checking for python2.4
    ... "Trent Mick" wrote: ... > Python and it is using Un*x-style process return values. ... Cygwin behaves exactly as Linux in this case. ... George ...
    (comp.lang.python)
  • Re: Find out username and UID/GID
    ... > how can I find out the username and it's UID and GID on a linux system, ... > using the most recent python version? ...
    (comp.lang.python)
  • Re: baduK 0.1 released
    ... Linux system. ... and the error message showed a little ^ under the r in for. ... I'd guess your problem is that your old Red Hat is running an old version of Python. ... I'm not sure about earlier versions, but my Linux box runs RedHat9.0, and that version of Python is 2.2 So glGo and anything else requiring Python 2.3 won't run. ...
    (rec.games.go)
  • Re: i386 with PAE or AMD64 on PowerEdge with 4G RAM
    ... lxml 1.2, because I need to add an oracle library to it. ... des@des ~% python --version ... distros I checked (and by far the best Linux system of the bunch), ...
    (freebsd-hackers)
  • Re: Installing Python 2.4 on Linux
    ... > I can install Python 2.4 on the Fedora 3 Linux system, ... > because they were dependent on the Python 2.3 installation. ... > use Python 2.4 without killing all the commands that depend on Python ...
    (comp.lang.python)