[Tutor] MemoryError

Liam Clarke cyresse at gmail.com
Thu Dec 9 11:04:04 CET 2004


Well, I figured out the memory error relatively easily once I poked
some stuff, I was using codeSt.find instead of codeSt.index, so it was
returning no matches as -1, index raises an error for me, and I wasn't
catering for that -1. The MemoryError occurred when Python wanted to
slice from 160,000 to -1 or 0.

Was quite funny watching 1 Gb of paging file disappear in seconds.

But, I give up. Now, I've got several more bugs pop up. I've got an
index of integers that has the occasional index stored as a string. I
have indexes that start pointing at the right place, but when it comes
time to slice, the right place has moved. Unsure why, I'm specifically
moving from highest to lowest to avoid messing with the index values.
Even if nothing changes, my stored indexes go off course. This is
yuck.

So, I'm going to throw caution to the wind, and try an re approach. It
can't be any more unwieldy and ugly than what I've got going at the
moment.

Thanks for all the help, I'm off to get myself another problem.

Regards,

Liam Clarke

On Wed, 08 Dec 2004 15:25:30 -0800, Jeff Shannon <jeff at ccvcorp.com> wrote:
> Liam Clarke wrote:
> 
> >>I'm not sure why you're getting the MemoryError, but it'd be easier to
> >>figure out if you posted the entire text of the traceback.
> >
> > Traceback: <usual bit about in module..>
> >
> > Line 39: seg=codeSt[element:endInd+len(endStr]
> > MemoryError
> >
> > Hehe. Helpful, no?
> 
> Actually, it was the "usual bit about in module" that might *be*
> helpful. ;)  Often, something can be determined by the sequence of
> function calls listed there.  Though I suppose, now that I think of
> it, that since your code is all module-level, there wouldn't be any
> function stack in this case...   Still, in general, when asking for
> help with something that throws an exception, it's always best to copy
> & paste the entire text of the exception.
> 
> One thing that I've noticed, which I thought was just a typo in your
> original email but which is duplicated again here (it's not present on
> the web page you linked to) -- you have a mismatched parenthesis in
> your len() call.  It's "[ ... len(endstr]" -- there's no ')' to close
> the function call.  Given that this typo isn't on the web page, I'm
> not sure whether it's actually there in the code you're running or
> not.  I'd have *thought*, however, that if it *is* present, you'd get
> a syntax error rather than a memory error, so it's probably not there
> but you should check it anyhow.  :)
> 
> 
> 
> Jeff Shannon
> Technician/Programmer
> Credit International
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


-- 
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.


More information about the Tutor mailing list