[PATCH] - Stripping "g" from vgs output case-insensitive runs faster
by Marcelo Moreira de Mello
Hello guys,
I was working in a case reported at BZ#729139 (from Satellite) and I
proposed a patch to strip the "g" from vgs. Looking the upstream, I
realized that this issue already were fixed in upstream .
Although, make some tests, this patch attached runs quite faster. Take
a look below:
notebook $> cat a1.py
import re
v = "16.00g"
for i in range(1000000):
free = re.sub("(?i)G","",v)
free = int(float(free))
v = "16.00g"
notebook $> time python a1.py
real 0m9.407s
user 0m9.286s
sys 0m0.060s
===================
notebook $> cat a2.py
v = "16.00g"
for i in range(1000000):
free = v.lower().replace("g","")
free = int(float(free))
v = "16.00g"
notebook $> time python a2.py
real 0m2.343s
user 0m2.292s
sys 0m0.041s
Follow the patch for approval.
Cheers,
Marcelo Moreira de Mello
--
Marcelo Moreira de Mello
RHCA RHCSS RHCVA
Software Maintenance Engineer/SEG
gpg id: 2048R/FDB110E5
gpg fingerprint: 3BE7 EF71 4DD7 6812 D309 8F18 BD42 D095 FDB1 10E5