summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-05-17 15:07:44 +0100
committerBenjamin Schubert <contact@benschubert.me>2019-05-29 19:47:57 +0100
commitd1fa3bb34147ba2d14abd10e9343de61425e5c75 (patch)
tree01f921d426d49f46c13fa455a2d40da13367bf20
parent4ce763851a07bd7aeb9593b60248467932d4bfbc (diff)
downloadbuildstream-d1fa3bb34147ba2d14abd10e9343de61425e5c75.tar.gz
_variables: make Variables extension class
Extension class are faster for access and take less memory than a normal Python class. Variables is self contained and easy to cythonize.
-rw-r--r--src/buildstream/_variables.pyx7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/buildstream/_variables.pyx b/src/buildstream/_variables.pyx
index 466187dde..0e3bdb29c 100644
--- a/src/buildstream/_variables.pyx
+++ b/src/buildstream/_variables.pyx
@@ -63,10 +63,13 @@ PARSE_EXPANSION = re.compile(r"\%\{([a-zA-Z][a-zA-Z0-9_-]*)\}")
# Raises:
# LoadError, if unresolved variables, or cycles in resolution, occur.
#
-class Variables():
+cdef class Variables:
- def __init__(self, node):
+ cdef object original
+ cdef dict _expstr_map
+ cdef public dict flat
+ def __init__(self, node):
self.original = node
self._expstr_map = self._resolve(node)
self.flat = self._flatten()