You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ConfigParser class in 2.7 is almost >50 times slower than in the 2.6 which for large files it renders it almost unusable. Actually the speed decrease depends on the amount of the stored data
Results from test program:
Python 2.7 (r27:82500, Sep 16 2010, 18:02:00)
on 3.5GHz Fedora14 64bit machine
ConfigParser 166.307140827
RawConfigParser 0.1887819767
Python 2.6.4 (r264:75706, Jun 4 2010, 18:20:31)
on 3.0GHz Fedora13 64bit machine
ConfigParser 4.24494099617
RawConfigParser 0.172905921936
Commenting-out the c.set(section,"item#%d"%(i),str(i)) calls shows that that is not where the problem lies for the ConfigParser() class.
The issue seems confined to ConfigParser.get().
The RawConfigParser() class doesn't seem to have the same issue.
Looking at the 2.7 code for ConfigParser.get() shows that it is doing a lot more than just getting. For example, it does a full copy of defaults dictionary on every call !?
Activity
vlachoudis commentedon Feb 1, 2011
The ConfigParser class in 2.7 is almost >50 times slower than in the 2.6 which for large files it renders it almost unusable. Actually the speed decrease depends on the amount of the stored data
Results from test program:
Python 2.7 (r27:82500, Sep 16 2010, 18:02:00)
on 3.5GHz Fedora14 64bit machine
ConfigParser 166.307140827
RawConfigParser 0.1887819767
Python 2.6.4 (r264:75706, Jun 4 2010, 18:20:31)
on 3.0GHz Fedora13 64bit machine
ConfigParser 4.24494099617
RawConfigParser 0.172905921936
skrah commentedon Feb 1, 2011
If OrderedDict is used, the test case quickly uses 8GB of memory. With
this change (I'm not suggesting this as a fix!), the timings are normal:
Index: Lib/ConfigParser.py
===================================================================
rhettinger commentedon Feb 2, 2011
Commenting-out the
c.set(section,"item#%d"%(i),str(i))calls shows that that is not where the problem lies for the ConfigParser() class.The issue seems confined to ConfigParser.get().
The RawConfigParser() class doesn't seem to have the same issue.
Looking at the 2.7 code for ConfigParser.get() shows that it is doing a lot more than just getting. For example, it does a full copy of defaults dictionary on every call !?
I'll look at it more shortly.
rhettinger commentedon Feb 2, 2011
Attaching a patch that fixes the algorithmic atrocities by using the Chainmap recipe:
http://code.activestate.com/recipes/305268-chained-map-lookups
rhettinger commentedon Feb 2, 2011
Fixed for 2.7 in r88318. Will make a similar fix for 3.1.4 and for 3.2.1.
rhettinger commentedon Feb 2, 2011
Attaching patch for Python 3.2.
Georg, I was think of waiting for 3.2.1 for this one, but it can go into 3.2.0 RC2 if you prefer.
birkenfeld commentedon Feb 2, 2011
3.2.1 should be fine.
rhettinger commentedon Feb 2, 2011
Fixed 3.1 in r88323.
rhettinger commentedon Feb 21, 2011
See r88469 and r88470.