diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-06-03 14:34:51 +0100 |
---|---|---|
committer | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-06-03 15:12:36 +0100 |
commit | 49262bda8e5bc3a1886256a848618ae22229135e (patch) | |
tree | 293e9190acf877b600f4afc17aa85fcf5af0969c /src/buildstream/_context.py | |
parent | 6b1f04769601328dfdd724103a4e08fc8623599c (diff) | |
download | buildstream-49262bda8e5bc3a1886256a848618ae22229135e.tar.gz |
_yaml.pyx: Forbid expected_type=Mapping, and remove isinstance check
Calls to `isinstance` can be particularily costly. Using type() is
much faster. The only known case where the `isinstance` was useful
is for dictionnaries where we would ask for a 'Mapping' instead.
Disallowing 'Mapping' for expected_type considerably speeds up the
calls to this functions.
Also add into NEWS
Diffstat (limited to 'src/buildstream/_context.py')
-rw-r--r-- | src/buildstream/_context.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py index 151ea636a..3f6e6ac3c 100644 --- a/src/buildstream/_context.py +++ b/src/buildstream/_context.py @@ -21,7 +21,6 @@ import os import shutil import datetime from collections import deque -from collections.abc import Mapping from contextlib import contextmanager from . import utils from . import _cachekey @@ -252,7 +251,7 @@ class Context(): # Load quota configuration # We need to find the first existing directory in the path of our # cachedir - the cachedir may not have been created yet. - cache = _yaml.node_get(defaults, Mapping, 'cache') + cache = _yaml.node_get(defaults, dict, 'cache') _yaml.node_validate(cache, ['quota', 'pull-buildtrees', 'cache-buildtrees']) self.config_cache_quota_string = _yaml.node_get(cache, str, 'quota') @@ -281,7 +280,7 @@ class Context(): cache, 'cache-buildtrees', ['always', 'auto', 'never']) # Load logging config - logging = _yaml.node_get(defaults, Mapping, 'logging') + logging = _yaml.node_get(defaults, dict, 'logging') _yaml.node_validate(logging, [ 'key-length', 'verbose', 'error-lines', 'message-lines', @@ -296,7 +295,7 @@ class Context(): self.log_message_format = _yaml.node_get(logging, str, 'message-format') # Load scheduler config - scheduler = _yaml.node_get(defaults, Mapping, 'scheduler') + scheduler = _yaml.node_get(defaults, dict, 'scheduler') _yaml.node_validate(scheduler, [ 'on-error', 'fetchers', 'builders', 'pushers', 'network-retries' @@ -406,10 +405,10 @@ class Context(): # project_name (str): The project name # # Returns: - # (Mapping): The overrides dictionary for the specified project + # (dict): The overrides dictionary for the specified project # def get_overrides(self, project_name): - return _yaml.node_get(self._project_overrides, Mapping, project_name, default_value={}) + return _yaml.node_get(self._project_overrides, dict, project_name, default_value={}) # get_strict(): # |