|
[Rivet] [Rivet-svn] r3587 - in trunk: . pyextAndy Buckley andy.buckley at ed.ac.ukTue Feb 28 16:16:32 GMT 2012
Woo! Nice one... that's something to bear in mind. On 28/02/12 14:07, blackhole at projects.hepforge.org wrote: > Author: hoeth > Date: Tue Feb 28 14:07:15 2012 > New Revision: 3587 > > Log: > lighthisto.py: Caching for re.compile(). In my case this reduced the calls to > re.compile by a factor of ~150, speeding up flat2aida and aida2flat by a factor > of 20-30. > > Modified: > trunk/ChangeLog > trunk/pyext/lighthisto.py > > Modified: trunk/ChangeLog > ============================================================================== > --- trunk/ChangeLog Mon Feb 27 13:23:33 2012 (r3586) > +++ trunk/ChangeLog Tue Feb 28 14:07:15 2012 (r3587) > @@ -1,3 +1,8 @@ > +2012-02-28 Hendrik Hoeth<hendrik.hoeth at cern.ch> > + > + * lighthisto.py: Caching for re.compile(). This speeds up aida2flat > + ant flat2aida by more than an order of magnitude. > + > 2012-02-27 Andy Buckley<andy.buckley at cern.ch> > > * doc/mk-analysis-html: Adding more LaTeX/text -> HTML conversion > > Modified: trunk/pyext/lighthisto.py > ============================================================================== > --- trunk/pyext/lighthisto.py Mon Feb 27 13:23:33 2012 (r3586) > +++ trunk/pyext/lighthisto.py Tue Feb 28 14:07:15 2012 (r3587) > @@ -553,6 +553,7 @@ > pat_comment = re.compile('^#|^\s*$') > pat_property = re.compile('^(\w+?)=(.*)$') > pat_path_property = re.compile('^(\S+?)::(\w+?)=(.*)$') > + pat_paths = {} > > def __init__(self, plotpaths=None, addfiles=[]): > """ > @@ -633,7 +634,9 @@ > if m: > tag, pathpat = m.group(1,2) > # pathpat could be a regex > - if tag == section and re.match(pathpat,hpath): > + if not self.pat_paths.has_key(pathpat): > + self.pat_paths[pathpat] = re.compile(pathpat) > + if tag == section and self.pat_paths[pathpat].match(hpath): > startreading = True > if section in ['SPECIAL']: > ret[section] = '' > _______________________________________________ > Rivet-svn mailing list > Rivet-svn at projects.hepforge.org > http://www.hepforge.org/lists/listinfo/rivet-svn > -- Dr Andy Buckley SUPA Advanced Research Fellow Particle Physics Experiment Group, University of Edinburgh The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.
More information about the Rivet mailing list |