Skip to content

Conversation

@nineteendo
Copy link
Contributor

@nineteendonineteendo commented Apr 10, 2024

Benchmark:

::test.bat@echooffecho 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/

@nineteendonineteendo marked this pull request as ready for review April 11, 2024 06:03
@nineteendonineteendo marked this pull request as draft April 12, 2024 06:22
Co-authored-by: Eryk Sun <eryksun@gmail.com>
@nineteendonineteendo marked this pull request as ready for review April 12, 2024 07:51
@nineteendo
Copy link
ContributorAuthor

@serhiy-storchaka, thoughts?

@serhiy-storchaka
Copy link
Member

How does it differ from lexists()?

@nineteendo
Copy link
ContributorAuthor

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

@nineteendonineteendo deleted the extend-os.path.exists branch April 12, 2024 11:45
Sign up for freeto 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

@nineteendo@serhiy-storchaka