Re: creating/modifying sparse files on linux
- From: Trent Mick <trentm@xxxxxxxxxxxxxxx>
- Date: Wed, 17 Aug 2005 13:42:10 -0700
[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
.
- References:
- creating/modifying sparse files on linux
- From: draghuram@xxxxxxxxx
- creating/modifying sparse files on linux
- Prev by Date: Re: win32pipe.popen3
- Next by Date: Re: creating/modifying sparse files on linux
- Previous by thread: creating/modifying sparse files on linux
- Next by thread: Re: creating/modifying sparse files on linux
- Index(es):
Relevant Pages
|
|