From d40cd3ec6b9afe563ad0ec14173ace2d665861d1 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 24 Oct 2018 18:15:55 +0200 Subject: [PATCH] Use functools.lru_cache with _getconftest_pathlist For pytest's own suite the `cache_info()` looks as follows: > session.config._getconftest_pathlist.cache_info() CacheInfo(hits=231, misses=19, maxsize=None, currsize=19) While it does not really make a difference for me this might help with larger test suites / the case mentioned in https://github.com/pytest-dev/pytest/issues/2206#issuecomment-432623646. --- src/_pytest/config/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 88cbf14ba..9769eb813 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1,6 +1,7 @@ """ command line options, ini-file and conftest.py processing. """ from __future__ import absolute_import, division, print_function import argparse +import functools import inspect import shlex import types @@ -893,6 +894,7 @@ class Config(object): assert type is None return value + @functools.lru_cache(maxsize=None) def _getconftest_pathlist(self, name, path): try: mod, relroots = self.pluginmanager._rget_with_confmod(name, path)