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","30 000,314572800"]
fd = open("testfile" , "w")
fd.seek(options .size-1)
fd.write("a")
for drange in options.ranges:
off = int(drange.spli t(",")[0])
len = int(drange.spli t(",")[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?
Thanks,
Raghu.
Aug 17 '05
10 5695
"dr*******@gmai l.com" <dr*******@gmai l.com> 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
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Troy |
last post by:
Hi-
I am attempting to set up an RSS feed using PHP. It would be convenient for
me to embed PHP into an xml file like I would do to an HTML file in order to
create the XML, however the apache server does not realize that it's PHP
content and the PHP engine is not run against that code. so I have to call
it feed.php instead of feed.xml, and most of the rss readers don't
appreciate this.
My alternative is to create the XML file every...
|
by: Hu Nan |
last post by:
DB2 UDB 8.1 on Red Hat Linux 8:
Just installed two Linux machines with UDB 8.1. When creating stored
procedure, like "create procedure p1() begin end", got error like:
SQL0035N The file "P4265487.msg" cannot be opened.
Checked /home/db2inst1/sqllib/function/routine, one machine has no
sqlproc subfolder there; another has sqlproc/TEST/DB2INST1/tmp, but
only Pxxxxxxx.sqc files, couldn't find Pxxxxxxx.msg files.
|
by: Barkster |
last post by:
I've been using Dreamweaver to create my php pages and love the
functionality but when I start modifying code I start wondering if I
should be something else because it always throws off the extensions.
I like the fact that dreamweaver will insert some of the tedious code
for me but are there any php GUI's that are similar to dreamweaver?
I've downloaded a few paid scripts and see the use of *.tpl files and
wonder how they design that and...
|
by: djhulme |
last post by:
Hi,
I'm using GCC. Please could you tell me, what is the maximum number of
array elements that I can create in C, i.e.
char* anArray = (char*) calloc( ??MAX?? , sizeof(char) ) ;
I've managed to create arrays using DOUBLE data types, but when I try
to access the array, the compiler complains that the number is not an
INT, i.e.
|
by: deLenn |
last post by:
Hi,
Does scipy have an equivalent to Matlab's 'find' function, to list the
indices of all nonzero elements in a sparse matrix?
Cheers.
| |
by: mediratta |
last post by:
Hi,
I want to allocate memory for a large matrix, whose size will be
around 2.5 million x 17000. Three fourth of its rows will have all
zeroes, but it is not known which will be those rows. If I try to
allocate memory for this huge array, then I get a segmentation fault
saying:
Program received signal SIGSEGV, Segmentation fault.
0xb7dd5226 in mallopt () from /lib/tls/i686/cmov/libc.so.6
|
by: adam.kleinbaum |
last post by:
Hi there,
I'm a novice C programmer working with a series of large (30,000 x
30,000) sparse matrices on a Linux system using the GCC compiler. To
represent and store these matrices, I'd like to implement the sparse
matrices as a doubly-linked list, in which each non-zero cell is
stored roughly as follows:
int rownum
int colnum
|
by: DanielJohnson |
last post by:
I have a small project which has around 10 .py files and I run this
project using command line arguments. I have to distribute this
project to somebody.
I was wondering how can I make an executable or some kind of
installer, so that end user doesn't need to compile and worry if he/
she has Python installed or not ?
Every help is greatly appreciated.
|
by: ishakteyran |
last post by:
hello to all.. i have a realy tough assignment which requires me to add, substract, multiply, and get inverse of non-sparse and sparse matrixes..
in a more clear way it wants me to to the operations listed above between two sparse, or non-sparse or a sparse and a non-sparse matrix..
for the operations an the matrixes of same kind, say sparse matrix, it seems rather easy .. but what makes me cobfuse is how to operate a sparse with a...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |