Changeset 2427


Ignore:
Timestamp:
Mar 11, 2010 10:06:30 PM (9 years ago)
Author:
jwatson
Message:

Added logic to automatically disable and re-enable garbage collection at various sane points in the PySP extensive form writer, in order to (noticeably) improve performance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pysp/trunk/coopr/pysp/ef.py

    r2418 r2427  
    55import traceback
    66import copy
     7import gc
    78
    89from coopr.pysp.scenariotree import *
     
    575576   # construct instances for each scenario
    576577   #
     578
     579   # the construction of instances takes little overhead in terms of
     580   # memory potentially lost in the garbage-collection sense (mainly
     581   # only that due to parsing and instance simplification/prep-processing).
     582   # to speed things along, disable garbage collection if it enabled in
     583   # the first place through the instance construction process.
     584   # IDEA: If this becomes too much for truly large numbers of scenarios,
     585   #       we could manually collect every time X instances have been created.
     586
     587   re_enable_gc = False
     588   if gc.isenabled() is True:
     589      re_enable_gc = True
     590      gc.disable()
    577591
    578592   scenario_instances = {}
     
    617631      scenario_instances[scenario._name] = scenario_instance
    618632
     633   if re_enable_gc is True:
     634      gc.enable()
     635
    619636   print ""
    620637
Note: See TracChangeset for help on using the changeset viewer.