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/source.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/source.py')
-rw-r--r-- | src/buildstream/source.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/buildstream/source.py b/src/buildstream/source.py index f6cefb386..9fc9cf17d 100644 --- a/src/buildstream/source.py +++ b/src/buildstream/source.py @@ -162,7 +162,6 @@ Class Reference """ import os -from collections.abc import Mapping from contextlib import contextmanager from . import _yaml, utils @@ -1280,7 +1279,7 @@ class Source(Plugin): sources = project.first_pass_config.source_overrides else: sources = project.source_overrides - cls.__defaults = _yaml.node_get(sources, Mapping, meta.kind, default_value={}) + cls.__defaults = _yaml.node_get(sources, dict, meta.kind, default_value={}) cls.__defaults_set = True # This will resolve the final configuration to be handed @@ -1288,7 +1287,7 @@ class Source(Plugin): # @classmethod def __extract_config(cls, meta): - config = _yaml.node_get(cls.__defaults, Mapping, 'config', default_value={}) + config = _yaml.node_get(cls.__defaults, dict, 'config', default_value={}) config = _yaml.node_copy(config) _yaml.composite(config, meta.config) |