<commit_before>import importlib


class Lazy(object):

    __slots__ = ('_path', '_value')

    def __init__(self, path=None):
        self._path = path
        self._value = None

    def __call__(self, *args, **kwargs):
        return self._obj(*args, **kwargs)

    def __iter__(self):
        return self._obj.__iter__()

    def __str__(self):
        return str(self._obj)

    def __getitem__(self, item):
        return self._obj[item]

    def __getattr__(self, attr):
        return getattr(self._obj, attr)

    def __get__(self, instance, owner):
        if not issubclass(owner, Route):
            return self._obj
        route = instance
        value = (
            route.original_handler._obj
            if isinstance(route.original_handler, Lazy) else
            route.original_handler
        )
        route.handler = value
        return value

    @property
    def _obj(self):
        if self._value is None:
            module_name, obj_name = self._path.rsplit('.', 1)
            module = importlib.import_module(module_name)
            self._value = getattr(module, obj_name)
        return self._value


class Route(object):

    handler = Lazy()

    def __init__(self, path, handler):
        self.path = path
        self.original_handler = handler<commit_msg>Lazy's obj became public<commit_after>import importlib


class Lazy(object):

    __slots__ = ('_path', '_value')

    def __init__(self, path=None):
        self._path = path
        self._value = None

    def __call__(self, *args, **kwargs):
        return self.obj(*args, **kwargs)

    def __iter__(self):
        return self.obj.__iter__()

    def __str__(self):
        return str(self.obj)

    def __getitem__(self, item):
        return self.obj[item]

    def __getattr__(self, attr):
        return getattr(self.obj, attr)

    def __get__(self, instance, owner):
        if not issubclass(owner, Route):
            return self.obj
        route = instance
        value = (
            route.original_handler.obj
            if isinstance(route.original_handler, Lazy) else
            route.original_handler
        )
        route.handler = value
        return value

    @property
    def obj(self):
        if self._value is None:
            module_name, obj_name = self._path.rsplit('.', 1)
            module = importlib.import_module(module_name)
            self._value = getattr(module, obj_name)
        return self._value


class Route(object):

    handler = Lazy()

    def __init__(self, path, handler):
        self.path = path
        self.original_handler = handler
{'fraction_non_alphanumeric': 0.10057803468208093, 'fraction_numerical': 0.0007707129094412332, 'mean_word_length': 2.135265700483092, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '875640', 'n_tokens_mistral': 768, 'n_tokens_neox': 738, 'n_words': 188}