Skip to content

gh-117705: Add follow_symlinks to os.path.exists() - #117729

Closed
nineteendo wants to merge 8 commits into
python:mainfrom
nineteendo:extend-os.path.exists
Closed

gh-117705: Add follow_symlinks to os.path.exists()#117729
nineteendo wants to merge 8 commits into
python:mainfrom
nineteendo:extend-os.path.exists

Conversation

@nineteendo

@nineteendonineteendo commented Apr 10, 2024

Copy link
Copy Markdown
Contributor

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/

@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 <eryksun@gmail.com>
@nineteendo
nineteendo marked this pull request as ready for review April 12, 2024 07:51
@nineteendo

Copy link
Copy Markdown
ContributorAuthor

@serhiy-storchaka, thoughts?

@serhiy-storchaka

Copy link
Copy Markdown
Member

How does it differ from lexists()?

@nineteendo

Copy link
Copy Markdown
ContributorAuthor

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

@nineteendo
nineteendo 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