Re: OK to memoize re objects?

2009-09-22 Thread Hyuga
On Sep 21, 11:02 am, Nobody nob...@nowhere.com 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

Re: OK to memoize re objects?

2009-09-21 Thread kj
In mailman.120.1253406305.2807.python-l...@python.org Robert Kern robert.k...@gmail.com 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

Re: OK to memoize re objects?

2009-09-21 Thread Ethan Furman
kj wrote: In mailman.120.1253406305.2807.python-l...@python.org Robert Kern robert.k...@gmail.com 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

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-ed

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

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-compiling

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,

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