diff configmix/config.py @ 552:39e5d07d8dbc

Provide a C implementation of configmix.config._split_filters. This is needed as precondition for implementation interpolate_variables in C also. Currently the speedup is not measurable but it does not hurt also. Also provide some unit-tests for _split_filters().
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 02 Jan 2022 20:40:09 +0100
parents 4c968c5cfce6
children 9d2bd411f5c5
line wrap: on
line diff
--- a/configmix/config.py	Sun Jan 02 16:05:35 2022 +0100
+++ b/configmix/config.py	Sun Jan 02 20:40:09 2022 +0100
@@ -32,12 +32,13 @@
 from .constants import REF_NAMESPACE, NONE_FILTER, EMPTY_FILTER
 try:
     from ._speedups import (fast_unquote, fast_quote, fast_pathstr2path,
-                            _fast_split_ns)
+                            _fast_split_ns, _fast_split_filters)
 except ImportError:
     fast_unquote = None
     fast_quote = None
     fast_pathstr2path = None
     _fast_split_ns = None
+    _fast_split_filters = None
 
 
 _MARKER = object()
@@ -397,7 +398,7 @@
     _split_ns = _py_split_ns
 
 
-def _split_filters(varname):
+def _py_split_filters(varname):
     """Split off the filter part from the `varname` string
 
     :type varname: str
@@ -418,6 +419,12 @@
         return (name, [])
 
 
+if _fast_split_filters:
+    _split_filters = _fast_split_filters
+else:
+    _split_filters = _py_split_filters
+
+
 class Configuration(CoercingMethodsMixin, _AttributeDict):
 
     """The configuration dictionary with attribute support or