Danek Duvall wrote: > On Tue, Jan 06, 2009 at 04:57:02PM -0600, Shawn Walker wrote: > >> From what I understand, the re module has an internal cache that >> automatically does this for re.search and re.match. Hence why re.purge() >> exists. > > Huh. So why bother having a re.compile() at all?
I have no idea. I guess because it's internal cache is limited to a max of 100 and you *really* want to be certain? My only other idea is that re.compile returns a pattern object, so if you needed access to that, you'd have to use re.compile. If you look at pydoc sre, re, etc. you'll notice several references to the cache but no further documentation on it. The mailing list posts I've found suggest that only certain functions in re use the cache; such as search(), match() and one or two others. >>> done the same way that we have PkgFmri and MatchingPkgFmri classes. >> They don't seem to be related. Those classes appear to be for >> validation, while mine is to extract string components for filtering (not >> really validation). > > Ignore the use in client.py -- that just uses the fact that the constraints > for being a MatchingPkgFmri are looser than for being a PkgFmri. The main > use of the class is in image.py, on line 1806, where they definitely are > used for filtering. Ah, okay. >> I would also be concerned about the overhead of using a class like that. > > And I'd be wary of using regular expressions when speed is required, too. I'm not aware of a better option to perform the actual matching since the python regex engine is written in C. I could probably perform the splits of the version string manually though instead (my first version did that). > Why would a separate class impact performance here? The usage of the class was murky to me. It seemed like I would have to create an instance of the class for each comparison; but now I see that I only need one instance for each version string and then I could use a method off that for comparison with each fmri I retrieve from the catalog. I could see possibly inheriting from MatchingPkgFmri and then adding a "is_version_match" method or changing MatchingPkgFmri. >> However, I could be convinced that this should be a method on the PkgFmri >> class, such as "is_matching_version" (name suggestions?). Would that >> suffice? > > Why would you put a method on PkgFmri and not on Version? I'm confused now. MatchingPkgFmri inherits from PkgFmri. Should this be a MatchingVersion class that inherits from Version instead? Cheers, -- Shawn Walker _______________________________________________ pkg-discuss mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/pkg-discuss
