Follow up to https://github.com/pytest-dev/pytest/pull/7366#pullrequestreview-430148146
Investigate whether caching the required plugins check would make sense, and implement the cache if this is indeed worthwhile. Please see the link above for thread describing this in more detail. At a high level, we would make a cache ( or cache like object ) that would declare whether requirements have been met for required_plugins so we didn't have to recompute its value
IIUC the reason @RonnyPfannschmidt suggests to cache here is to avoid the packaging imports.
I only made the change to lazy-import packaging recently in f1f9c7792 (not released yet), to shave off some 20-30ms startup time (IIRC). But I do not think it is critical, or worth complicating the code for. Also, only people who use required_plugins will "pay" the cost (now the special case we discussed in https://github.com/pytest-dev/pytest/pull/7330/files#r439052821 makes more sense :grin: ) which seems OK to me.
So I'm -1 on caching the required plugins check.
Based on the information @bluetech provided i agree with skipping this, also I realized that the cases where this makes a difference, people can defer it to other mandatory environmental setups
I'm in agreement on skipping, thanks for the info @bluetech
Closing this @RonnyPfannschmidt
Most helpful comment
IIUC the reason @RonnyPfannschmidt suggests to cache here is to avoid the
packagingimports.I only made the change to lazy-import
packagingrecently in f1f9c7792 (not released yet), to shave off some 20-30ms startup time (IIRC). But I do not think it is critical, or worth complicating the code for. Also, only people who userequired_pluginswill "pay" the cost (now the special case we discussed in https://github.com/pytest-dev/pytest/pull/7330/files#r439052821 makes more sense :grin: ) which seems OK to me.So I'm -1 on caching the required plugins check.