diff --git a/src/sonic-config-engine/lazy_re.py b/src/sonic-config-engine/lazy_re.py deleted file mode 100644 index b51c385c1cc..00000000000 --- a/src/sonic-config-engine/lazy_re.py +++ /dev/null @@ -1,22 +0,0 @@ -# monkey patch re.compile to improve import time of some packages - -import re - -_orig_re_compile = re.compile - - -def __re_compile(*args, **kwargs): - class __LazyReCompile(object): - def __init__(self, *args, **kwargs): - self.args = args - self.kwargs = kwargs - self.pattern_obj = None - - def __getattr__(self, name): - if self.pattern_obj is None: - self.pattern_obj = _orig_re_compile(*self.args, **self.kwargs) - return getattr(self.pattern_obj, name) - return __LazyReCompile(*args, **kwargs) - -re.compile = __re_compile - diff --git a/src/sonic-config-engine/setup.py b/src/sonic-config-engine/setup.py index 236d39e7117..d19fcb1e5b6 100644 --- a/src/sonic-config-engine/setup.py +++ b/src/sonic-config-engine/setup.py @@ -40,7 +40,6 @@ # Common modules for python2 and python3 py_modules = [ 'config_samples', - 'lazy_re', 'minigraph', 'openconfig_acl', 'portconfig', diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index dad68118902..bd528c64e75 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -17,15 +17,6 @@ See usage string for detail description for arguments. from __future__ import print_function -# monkey patch re.compile to do lazy regular expression compilation. -# This is done to improve import time of jinja2, yaml, natsort modules, because they -# do many regexp compilation at import time, so it will speed up sonic-cfggen invocations -# that do not require template generation or yaml loading. sonic-cfggen is used in so many places -# during system boot up that importing jinja2, yaml, natsort every time -# without lazy regular expression compilation affect boot up time. -# FIXME: remove this once sonic-cfggen and templates dependencies are replaced with a faster approach -import lazy_re - import argparse import contextlib import jinja2