hi all,
i am writing some software to model polymerisation kinetics and have
created a way of doing so which involves taking ever smaller slices of
time to model until some sort of convergence was observed in the
results.
so far so good, but i was using 'for i in the range(iteration s):' a for
loop over each slice of time, where the number of iterations was
getting into the tens of millions. up until about 125,000,000 it
worked, then i got a MemoryError.
now i wasn't surprised to get a memory error eventually because what i
was doing was some serous number-crunching. but it didn't occur to me
where it was at first. i had to keep some results in memory to
calculate something at the end, but that was about a million integers,
not that hard with 512 Mb of RAM. then i thought it might be something
structural in the way python works, but i couldn't guess at what it
might be.
thinking about it a bit more, i remembered having read that the
for-loop declaration i used actually created a list of integers, which
would be eating up over half of my memory before i'd even started doing
anything. the program was creating a directory as instructed, then
doing nothing, just churning, which made it clear that the problem was
encountered right at the start of the program. that helped clear it up,
but i was surprised that something as innocuous as the for-loop was
creating such a problem. i changed it to a while-loop and it worked
fine.
has anyone else bumped up against this problem before? i suppose
for-loops with 250 million iterations are seldom used in most
applications. it was just the first time i'd ever solved a problem by
actually having some insight into how python works at a slightly lower
level.
anyway, sorry to be so long-winded. i'm just glad the damn thing's
working again... :)
sam 1 1897
sam wrote:
hi all,
...
has anyone else bumped up against this problem before? i suppose
for-loops with 250 million iterations are seldom used in most
applications. it was just the first time i'd ever solved a problem by
actually having some insight into how python works at a slightly lower
level.
Sam,
The problem is not with the 'for' operator, but the fact that the
range() operator creates the iterable list (in this case, with 250
million elements) prior to beginning the loop.
Try using xrange() with the same syntax, which returns items from a
tuple (NOT a list, if it matters to you) just-in-time and discards
them, much like FOR as used in a BASIC context.
xrange() is somewhat less flexible, though, and may or may not suit
your needs. If not, use 'while' instead, and set your own loop exit
conditions. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: DJTB |
last post by:
zodb-dev@zope.org]
Hi,
I'm having problems storing large amounts of objects in a ZODB.
After committing changes to the database, elements are not cleared from
memory. Since the number of objects I'd like to store in the ZODB is too
large to fit in RAM, my program gets killed with signal 11 or signal 9...
Below a minimal working (or actually: it doesn't work because of memory
|
by: jfixsen |
last post by:
Hello!
Oracle 9.2.0.4
SunOS pchi-db01 5.8 Generic_108528-19 sun4u sparc
SUNW,Ultra-EnterpriseSystem = SunOS
Node = pchi-db01
Release = 5.8
KernelID = Generic_108528-19
Machine = sun4u
BusType = <unknown>
|
by: Tim Mulholland |
last post by:
I recently reinstalled everything on my computer:
Windows XP Pro (SP-2)
Office 2003 (SP1)
VS 2003 (7.1.3088)
..Net Framework (1.1.4322)
WMP 10.00.00.3646
Every time i try to open a specific ASP.Net project containing about 175
files The following error is logged under the Application folder in the
Event Viewer:
|
by: Steve Jorgensen |
last post by:
Hi folks,
I'm posting this message because it's an issue I come up against relatively
often, but I can't find any writings on the subject, and I haven't been able
to figure out even what key words one would use to look for it.
First, in broad philosophical terms, code actually -is- data. Code is the
data that's fed into a compiler, interpreter, or microprocessor that tells it
what to do. Code execution is, then, just a form another...
|
by: Trevor Hughes |
last post by:
Hello All
I have a database (Access 2000, running on Win 2000), which suffers from
bloat over a period of time. In order to solve the problem I set the
option to compact on exit. This however has caused a problem. The
permissions of the mdb file which are set to Everyone-Full control, are
reset when the database is compacted. The end result is the the users
get a message saying Access cannot locate the database. I can run it
with...
| |
by: Lloyd Sheen |
last post by:
This IDE is driving me nuts. I needed another button so I copied an
existing one, changed the Text and the id and position by drag and drop.
Well then I run and get the following:
Control 'Button19' of type 'Button' must be placed inside a form tag with
runat=server
Can the IDE not do what it is supposed to do. It seems that it is a fight
to make it do anything or did I do something wrong? It would seem silly to
have to create a...
|
by: matvdl |
last post by:
I have a system that was originally developed in asp - the pages are saved in
SQL (there are over 10,000 pages) and saved to a temp directory in the server
when requested by a client.
I have updated this system and changed the pages that are saved to the
server as aspx - everything works fine and pages can be served - but
Its not impossible for a single client to request 100 plus pages in one
session - as each page is requested it is...
|
by: jacob navia |
last post by:
As many people know, I think that garbage collection is a good
solution for many memory allocation problems.
I am aware however, that nothing is "the silver bullet", not
even the GC.
A recent article in slashdot
http://developers.slashdot.org/article.pl?sid=07/11/17/0552247
proves that.
|
by: =?Utf-8?B?R3JlZw==?= |
last post by:
I have no idea where to post this question, or even if its appropriate for me
to post it here. I don't know if installing a VB.Net program has caused the
problem I'm having or not. All I know is I did install a VB.Net program on my
desktop computer and lately its been acting very strangely. It could also be
the result of something else, but I'm not sure.
The symptom I'm having is the following.
When I start up my desktop computer I am...
|
by: stararic |
last post by:
hi, I'm writing a program a kind of calculator that should work with very big numbers (thousand of digits). So, numbers are rappresented by a struct that contains a pointer to integer, e 2 int for dimension of the array e number of digits.
the pointer is than used for the malloc of the array...
my 2 problems are:
1)some time, when I use my exp function I get the error:
*** glibc detected *** ./a.out: free(): invalid size: 0x0975a328...
|
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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |