Portage dbapi vs Gentoolkit api

posted on April 12, 2011

Wrote  some code to read list of installed packages (CPV - category, package, version) using the Gentoolkit api, as well as the Portage dbapi. Here’s the results !

#!/usr/bin/env python

from time import time

startg = time ()
from gentoolkit.helpers import get_installed_cpvs
for cpv in sorted (get_installed_cpvs ()):
print cpv
endg = time ()

startp = time ()
from portage.dbapi.vartree import vartree
vt = vartree ()
for cpv in sorted (vt.getallcpv ()):
print cpv
endp = time ()

print "Gentoolkit", endg - startg
print "Portage", endp - startp
Gentoolkit 2.60817313194
Portage 0.0787289142609

Portage dbapi is way faster than Gentoolkit :)