Hello, Am Montag, 6. Juli 2015 schrieb Steve Beattie: > On Sun, Jul 05, 2015 at 03:53:20PM +0200, Christian Boltz wrote: > > Also wrap the two remaining regexes in '^(...)+$' instead of doing > > it inside validate_profile_mode(). This makes the code more readable > > and also results in a 2% performance improvement when parsing > > profiles. > > I'm surprised that it was noticeable. Python supposedly caches re > match patterns, so that repeatedly compiling over and over isn't > supposed to take a significant amount of time. Though repeatedly > constructing new strings over and over will take time.
It isn't the first time we see an improvement by using re.compile() and even more by avoiding repeated re.compile(), so I'm not too surprised - the only thing that surprised me is that it's noticable because the regex work in validate_profile_mode is only a small part of parsing profiles. BTW: I measured the performance using the testcase from patch 69, which means parsing about 1300 profiles. Regards, Christian Boltz -- Die beste SuSE glaub ich Dir gern, von mir aus auch gern die beste Linux Distro, aber die beste Susi kann ich dir nicht unterschreiben... Da gibt es Features, die wird die SuSE AG nie in eine Linux-Distro unterbringen ;-) [Manfred Tremmel in suse-linux] -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor