-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion on removing the py dependency for path handling #6130
Comments
Killing the pylib dependency in general is a planned long term change |
We could have objects based on pathlib, with pylib methods mixed in that would issue a DeprecationWarning maybe. |
In the middle of the night I remembered that the hooks have DI parameters, so it should be simple to start passing new arguments (with new names) and if the signature contains the old parameter names, issue the deprecation warning there. I think it would be nice if we split the parameter names for dirs and files too. Currently it's "path" and plugins have to check if it's a file if they are unsure. If it was "dirname" and "filename" it would be clearer. If we also make the instantiation of the Path objects lazy at the call site and the core code uses pure strings, then the cutoff could be pretty clean and if you have no deprecated usage you would mostly not have the performance hit of the old stuff. I also had the idea that we could go through the entire filesystem from the very beginning (respecting ignore patterns?) and then look at an in-memory data structure instead of asking the filesystem over and over. I don't think pytest can, and wants to, support the filesystem changing significantly under its feet during a test session anyway. |
IIRC we discussed something like this (mainly for For tmpdir, we ended up having a separate Of course it remains to be seen if |
The py.path API isn't very good, isn't well documented and worse than that it's very different from the rest of the python ecosystem, so keeping it seems like a bad idea long term. |
@The-Compiler after initial expieriments a few years back im absolutely certain we should let the pylib api die |
Yeah, that sounds like a good idea in general (separate issue - please consider creating / owning it then). |
I had a look again at pytest performance, and was struck again by how many
stat
calls pytest performs. This seems to boil down to using the path classes from py for checking file existence, walking directory structures and such. Unfortunately instances of these are passed to plugins so aren't internal implementation details.I suggest we think of using plain strings as paths that are passed to plugins. This is obviously a breaking change so can't be done until pytest 6. It's not clear to me how we'd make deprecation warnings for this though :(
To take a concrete example of this being a problem, the test suite for the product I work on calls stat 79k times just for the collect phase. If I monkey patch stat to log the paths there are ~3k unique paths in the output. I can get a little performance boost by monkey patching stat to be cached:
That this can improve the performance is pretty silly :P
It seems like pytest could just use
os.walk
once and then use that data for the rest of the run of the program...The text was updated successfully, but these errors were encountered: