Skip to content

Conversation

@nineteendo
Copy link
Contributor

@nineteendo nineteendo commented Apr 10, 2024

Benchmark:

::test.bat
@echo off
echo existent && python -m timeit -s "import ntpath" "ntpath.lexists('test.bat')" && PCbuild\amd64\python.exe -m timeit -s "import ntpath" "ntpath.lexists('test.bat')"
echo non-existent && python -m timeit -s "import ntpath" "ntpath.lexists('foo.bar')" && PCbuild\amd64\python.exe -m timeit -s "import ntpath" "ntpath.lexists('foo.bar')"
existent 
5000 loops, best of 5: 47.9 usec per loop # before
5000 loops, best of 5: 46.8 usec per loop # after
# -> 1.02x faster
non-existent
10000 loops, best of 5: 21.8 usec per loop # before
20000 loops, best of 5: 16 usec per loop # after
# -> 1.36x faster

📚 Documentation preview 📚: https://cpython-previews--117729.org.readthedocs.build/

@nineteendo nineteendo marked this pull request as ready for review April 11, 2024 06:03
@nineteendo nineteendo marked this pull request as draft April 12, 2024 06:22
Co-authored-by: Eryk Sun <[email protected]>
@nineteendo nineteendo marked this pull request as ready for review April 12, 2024 07:51
@nineteendo
Copy link
Contributor Author

@serhiy-storchaka, thoughts?

@serhiy-storchaka
Copy link
Member

How does it differ from lexists()?

@nineteendo
Copy link
Contributor Author

It's more explicit, and it allows us to implement a faster lexists() on Windows without duplicating C code.

@nineteendo nineteendo closed this Apr 12, 2024
@nineteendo nineteendo deleted the extend-os.path.exists branch April 12, 2024 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants