473,409 Members | 2,022 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

Size limit on compiling?

I have a Python file of 1.2MB (it's a static database, not code, so it
really does have to be that big). It doesn't seem to get compiled when
imported (there's no .pyc file created), so importing it takes a few
seconds which I would really like to avoid. Is Python not compiling it
because of the large size? Is it because the whole file is on one really
long line? How can I fix this?
Jul 18 '05 #1
3 1174
In article <Ij***************@newshog.newsread.com>,
Leif K-Brooks <eu*****@ecritters.biz> wrote:

I have a Python file of 1.2MB (it's a static database, not code, so it
really does have to be that big). It doesn't seem to get compiled when
imported (there's no .pyc file created), so importing it takes a few
seconds which I would really like to avoid. Is Python not compiling it
because of the large size? Is it because the whole file is on one really
long line? How can I fix this?


Use a real database, or at least pickle.
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/

"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python
Jul 18 '05 #2
Leif K-Brooks wrote:

I have a Python file of 1.2MB (it's a static database, not code, so it
really does have to be that big). It doesn't seem to get compiled when
imported (there's no .pyc file created), so importing it takes a few
seconds which I would really like to avoid. Is Python not compiling it
because of the large size? Is it because the whole file is on one really
long line? How can I fix this?


If it's the main file, it won't get compiled anyway. Only files
that are imported are compiled. In any case, see Aahz' answer for the
best approach.

-Peter
Jul 18 '05 #3
On Thu, 26 Feb 2004 09:31:02 -0500, Peter Hansen <pe***@engcorp.com> wrote:
Leif K-Brooks wrote:

I have a Python file of 1.2MB (it's a static database, not code, so it
really does have to be that big). It doesn't seem to get compiled when
imported (there's no .pyc file created), so importing it takes a few
seconds which I would really like to avoid. Is Python not compiling it
because of the large size? Is it because the whole file is on one really
long line? How can I fix this?


If it's the main file, it won't get compiled anyway. Only files
that are imported are compiled. In any case, see Aahz' answer for the
best approach.

If your file is highly structured (or you can separately prepare a version that is),
you might consider accessing it via mmap and struct (or even without struct,
if it's e.g., a flat array of fixed-length strings). You could enhance this
by pre-computing an index and storing it at the end or beginning of the file,
maybe data for a dict of (offset,length) values, similarly packed/retrieved
from the raw binary file (byte string) format. If you open the file read-only,
an efficient OS will not even page in or allocate swap file space for anything
you don't access (though 1.2 mb these days is not a big worry ;-).
But if your data is complicated, pretty soon you'd be reinventing pickle
and various db things, and you might as well use what's available already.

Regards,
Bengt Richter
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: steve | last post by:
I am setting up a huge database in mysql, and I get the above error in Linux. I believe it is related to the size of one of my tables, which is 4,294,966,772 bytes in size. Can someone help. How...
2
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
1
by: Lelle | last post by:
Sorry for crossposting - sent to wrong group first hello ! does anyone have more information regarding this issue? http://www.systemwebmail.com/faq/2.3.aspx a.. Attachment Size Limit? ...
8
by: Ron | last post by:
Hi all, How do I determine the size of the tables I'm using? I looked under properties and it's not there. The book I just browsed said table is limited to 1GB. How do I find out what size my...
5
by: Jefferis NoSpamme | last post by:
Hi all, I'm trying to limit the file size of an image submission and I keep running into various problems. I've got most of it working, but I'm stumped and I have a basic question as to WHY this...
6
by: AB | last post by:
Hello all, I heard once that there is a limitation on the number of lines of code that a program can have when using C, but not for C++. Is this true? Any ideas?
1
by: HopfZ | last post by:
Internet Explorer 6 bookmarklets(favlets) has size limit. And its size limit depend on the kind of code. For example, CODE A and CODE B (below) are both at their size limit. CODE A does not work...
2
by: Harry | last post by:
Good Day To all, When i am declaring a array for e.g char ....it means i am declaring array of 45 characters each of which has a maximum,minimum value limit or range...for example in...
5
by: mohangupta13 | last post by:
hello everyone can anyone please tell me is there any limit on the size of the program you are creating. i mean i tried to declare an 10000 size long double array and the compilation error says...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
Oralloy
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.