I profiled an execution of "emerge -pv sed" to look for easy ways to increase
the speed of that command. The following 2-line patch gives a 2% reduced run
time. The profile showed that regex matching accounts for 8.3% of the run
time, so these updated regular expressions are at least 25% quicker. I hoped
it would help more but it should all add up.
As I get more time I may look to submit other small improvements.
As for how the patch works, the version number part of a package name has many
options so that part of the regular expression is time consuming. It was
advantageous to use an assertion to visit that part of the expression less
often. Python since 2.4 supports what I've used so this should work on all
current versions.
Thank you.
Neil Cahill.
### patch ###
--- pym/portage/versions.py 2013-09-23 21:59:21.000000000 +0100
+++ pym/portage/versions.py 2013-10-08 14:48:11.178441337 +0100
@@ -45,8 +45,8 @@
# It must not begin with a hyphen,
# and must not end in a hyphen followed by one or more digits.
_pkg = {
- "dots_disallowed_in_PN": r'[\w+][\w+-]*?',
- "dots_allowed_in_PN": r'[\w+][\w+.-]*?',
+ "dots_disallowed_in_PN": r'[\w+][\w+-]*?(?![\w+])',
+ "dots_allowed_in_PN": r'[\w+][\w+.-]*?(?![\w+.])',
}
_v = r'(cvs\.)?(\d+)((\.\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\d*)*)'
### end patch ###