Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #15437 > unrolled thread

Re: memory management

Started byDave Angel <d@davea.name>
First post2011-11-07 15:50 -0500
Last post2011-11-07 15:50 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: memory management Dave Angel <d@davea.name> - 2011-11-07 15:50 -0500

#15437 — Re: memory management

FromDave Angel <d@davea.name>
Date2011-11-07 15:50 -0500
SubjectRe: memory management
Message-ID<mailman.2515.1320699053.27778.python-list@python.org>
On 11/07/2011 03:33 PM, Juan Declet-Barreto wrote:
> Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which ships with ESRI's ArcGIS. In addition, I am using some functions in the arcgisscripting Python geoprocessing module for geographic information systems (GIS) applications, which can complicate things. I am currently isolating standard library Python code (e.g., os.walk()) from the arcgisscripting module to evaluate in which module the environment crash is occurring.
You top-posted.  In this mailing list, one should type new information 
after the quoted information, not before.

Perhaps a pre-emptive strike is in order.  On the assumption that it may 
be a memory problem, how about you turn the app inside out.  Instead of 
walking the entire tree, getting a list with all the paths, and then 
working on the list, how about doing the work on each file as you get 
it.  Or even make your own generator from os.walk, so the app can call 
your logic on each file, and never have all the file (name)s in memory 
at the same time.


Generator:

def  filelist(top, criteria):
       for  a, b, c in os.walk():
              for fiile in files:
                    apply some criteria
                    yield file


Now the main app can iterate through this "list" in the usual way

for filename in filelist(top, "*.txt"):
        dosomething...



-- 

DaveA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web