Mercurial > hgrepos > Python > libs > ConfigMix
diff configmix/config.py @ 543:491413368c7c
Added also a fast C-implementation of configmix.config._split_ns
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 01 Jan 2022 18:01:32 +0100 |
| parents | f71d34dda19f |
| children | 325008573bc6 |
line wrap: on
line diff
--- a/configmix/config.py Fri Dec 31 21:24:16 2021 +0100 +++ b/configmix/config.py Sat Jan 01 18:01:32 2022 +0100 @@ -31,10 +31,11 @@ from .compat import u, uchr, n, str_and_u, PY2 from .constants import REF_NAMESPACE, NONE_FILTER, EMPTY_FILTER try: - from ._speedups import fast_unquote, fast_pathstr2path + from ._speedups import fast_unquote, fast_pathstr2path, _fast_split_ns except ImportError: fast_unquote = None fast_pathstr2path = None + _fast_split_ns = None _MARKER = object() @@ -362,7 +363,7 @@ pathstr2path = py_pathstr2path -def _split_ns(varname): +def _py_split_ns(varname): """Split the variable name string `varname` into the namespace and the namespace-specific name @@ -371,6 +372,9 @@ namespace-specific (variable-)name :rtype: tuple(str or None, str) + .. note:: The returned namespace may be an empty string if the namespace + separator is found. + """ ns, sep, rest = varname.partition(_NS_SEPARATOR) if sep: @@ -379,6 +383,12 @@ return (None, ns) +if _fast_split_ns: + _split_ns = _fast_split_ns +else: + _split_ns = _py_split_ns + + def _split_filters(varname): """Split off the filter part from the `varname` string
