Patchwork [bitbake-devel,06/16] data: Use direct iteration, not keys()

mail settings
Submitter Richard Purdie
Date Sept. 16, 2013, 9:53 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/58195/
State Accepted
Commit e63448d9ee331b0f45fb9a0197d0dbee49eb2fa0
Headers show


Richard Purdie - Sept. 16, 2013, 9:53 p.m.
Profiling shows the creation of keys() has overhead and we're better using
an iterator rather than the memory associated with the huge list of keys
when iterating the whoe datastore. We minimise the number of times
we do this to twice only per recipe.

Signed-off-by: Richard Purdie <>
 lib/bb/ | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


diff --git a/lib/bb/ b/lib/bb/
index e6d5232..beaf089 100644
--- a/lib/bb/
+++ b/lib/bb/
@@ -148,7 +148,7 @@  def expandKeys(alterdata, readdata = None):
         readdata = alterdata
     todolist = {}
-    for key in keys(alterdata):
+    for key in alterdata:
         if not '${' in key:
@@ -341,7 +341,7 @@  def build_dependencies(key, keys, shelldeps, vardepvals, d):
 def generate_dependencies(d):
-    keys = set(key for key in d.keys() if not key.startswith("__"))
+    keys = set(key for key in d if not key.startswith("__"))
     shelldeps = set(key for key in keys if d.getVarFlag(key, "export") and not d.getVarFlag(key, "unexport"))
     vardepvals = set(key for key in keys if d.getVarFlag(key, "vardepvalue"))