pytest-dev / pluggy

A minimalist production ready plugin system
https://pluggy.readthedocs.io/en/latest/
MIT License
1.24k stars 121 forks source link

faster baseline import #445

Open RonnyPfannschmidt opened 11 months ago

RonnyPfannschmidt commented 11 months ago

still breaking

this change youelds a speedup form 0.69s to 0.004s for pluggy imports, by deferring imports of the stdlib

RonnyPfannschmidt commented 11 months ago

@nicoddemus @bluetech i wonder if we can drop the custom parsing from pytest (for marks on hooks) else there is need for a _types module that gets lazyly imported using getattr

RonnyPfannschmidt commented 11 months ago

i also started https://discuss.python.org/t/deferred-computation-evalution-for-toplevels-imports-and-dataclasses/34173 as a result of this

RonnyPfannschmidt commented 11 months ago

hmm, i strongly dislike the current structure of this the proposal for python is also going nowhere

i strongly suspect that unless apipkg provides a example something similar wont go forward

bluetech commented 11 months ago

Deferring typing seems like too much to me...

Looking at python -Ximporttime output, importlib.metadata is a major culprit. Making it lazy (which is simpler to do) reduces the import time ~70ms -> ~30ms for me. I think we should start with this and maybe other simple imports if any and then evaluate typing separately.