Re: creating/modifying sparse files on linux

2005-08-18 Thread Benji York
Terry Reedy wrote: megastring = 100*'a' # t 1 sec on my machine (other than keep appending to a string until it reaches 1MB len)? You mean like (unexecuted) s = '' for i in xrange(100): s += 'a' #? This will allocate, copy, and deallocate 100 successively longer temporary

Re: creating/modifying sparse files on linux

2005-08-18 Thread [EMAIL PROTECTED]
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

Re: creating/modifying sparse files on linux

2005-08-18 Thread Mike Meyer
[EMAIL PROTECTED] [EMAIL PROTECTED] 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

Re: creating/modifying sparse files on linux

2005-08-17 Thread Trent Mick
[EMAIL PROTECTED] 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,3,314572800] fd = open(testfile,

Re: creating/modifying sparse files on linux

2005-08-17 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: options.size = 6442450944 options.ranges = [4096,1024,3,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

Re: creating/modifying sparse files on linux

2005-08-17 Thread Terry Reedy
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Is there any special support for sparse file handling in python? Since I have not heard of such in several years, I suspect not. CPython, normally compiled, uses the standard C stdio lib. If your system+C has a sparseIO lib, you

Re: creating/modifying sparse files on linux

2005-08-17 Thread [EMAIL PROTECTED]
Thanks for the info on xrange. Writing single char is just to get going quickly. I knew that I would have to improve on that. I would like to write chunks of 1MB which would require that I have 1MB string to write. Is there any simple way of generating this 1MB string (other than keep appending

Re: creating/modifying sparse files on linux

2005-08-17 Thread Terry Reedy
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thanks for the info on xrange. Writing single char is just to get going quickly. I knew that I would have to improve on that. I would like to write chunks of 1MB which would require that I have 1MB string to write. Is there any

Re: creating/modifying sparse files on linux

2005-08-17 Thread François Pinard
[EMAIL PROTECTED] Is there any simple way of generating this 1MB string (other than keep appending to a string until it reaches 1MB len)? You might of course use 'x' * 100 for fairly quickly generating a single string holding one million `x'. Yet, your idea of generating a sparse file is

Re: creating/modifying sparse files on linux

2005-08-17 Thread Bengt Richter
On 17 Aug 2005 11:53:39 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] 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 =