Re: OK to memoize re objects?

2009-09-22 Thread Hyuga
On Sep 21, 11:02 am, Nobody wrote: > On Mon, 21 Sep 2009 07:11:36 -0700, Ethan Furman wrote: > > Looking in the code for re in 2.5: > > _MAXCACHE = 100 > > On the other hand, I (a > > re novice, to be sure) have only used between two to five in any one > > program... it'll be a while before I hit

Re: OK to memoize re objects?

2009-09-21 Thread Steven D'Aprano
On Mon, 21 Sep 2009 13:33:05 +, kj wrote: > I find the docs are pretty confusing on this point. They first make the > point of noting that pre-compiling regular expressions is more > efficient, and then *immediately* shoot down this point by saying that > one need not worry about pre-compilin

Re: OK to memoize re objects?

2009-09-21 Thread Ethan Furman
Nobody wrote: On Mon, 21 Sep 2009 07:11:36 -0700, Ethan Furman wrote: Looking in the code for re in 2.5: _MAXCACHE = 100 On the other hand, I (a re novice, to be sure) have only used between two to five in any one program... it'll be a while before I hit _MAXCACHE! Do you know how m

Re: OK to memoize re objects?

2009-09-21 Thread Nobody
On Mon, 21 Sep 2009 07:11:36 -0700, Ethan Furman wrote: > Looking in the code for re in 2.5: > _MAXCACHE = 100 > On the other hand, I (a > re novice, to be sure) have only used between two to five in any one > program... it'll be a while before I hit _MAXCACHE! Do you know how many REs import-e

Re: OK to memoize re objects?

2009-09-21 Thread Ethan Furman
kj wrote: In Robert Kern writes: kj wrote: My Python code is filled with assignments of regexp objects to globals variables at the top level; e.g.: _spam_re = re.compile('^(?:ham|eggs)$', re.I) Don't like it. My Perl-pickled brain wishes that re.compile was a memoizing method, so that

Re: OK to memoize re objects?

2009-09-21 Thread kj
In Robert Kern writes: >kj wrote: >> >> My Python code is filled with assignments of regexp objects to >> globals variables at the top level; e.g.: >> >> _spam_re = re.compile('^(?:ham|eggs)$', re.I) >> >> Don't like it. My Perl-pickled brain wishes that re.compile was >> a memoizing method

Re: OK to memoize re objects?

2009-09-19 Thread Robert Kern
kj wrote: My Python code is filled with assignments of regexp objects to globals variables at the top level; e.g.: _spam_re = re.compile('^(?:ham|eggs)$', re.I) Don't like it. My Perl-pickled brain wishes that re.compile was a memoizing method, so that I could use it anywhere, even inside tig

OK to memoize re objects?

2009-09-19 Thread kj
My Python code is filled with assignments of regexp objects to globals variables at the top level; e.g.: _spam_re = re.compile('^(?:ham|eggs)$', re.I) Don't like it. My Perl-pickled brain wishes that re.compile was a memoizing method, so that I could use it anywhere, even inside tight loops, w