Add fast Windows implementation for os.path.isjunction

Open
#101,356 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Review the optimization discussed in #101324 and the entry points nt._isjunction(), ntpath.isjunction(), DirEntry.is_junction(), and pathlib.Path.is_junction(). Compare junction detection with the existing islink(), including the LSTAT fallback and mount-point reparse tag behavior. Done means the Windows implementation provides the requested behavior and an approximately 25% speedup without regressing shutil.rmtree() or pathlib.Path.is_junction().

Written by the indexing model from the issue text.

Description

OS-windows performance stdlib type-feature

Feature or enhancement

In #101324, @eryksun pointed out that we could also optimize os.path.isjunction(), and would like see the same ~25% speedup as for isdir, isfile and islink:

Maybe also add nt._isjunction() for the new ntpath.isjunction() test in 3.12. It's like islink(), except it checks for the tag IO_REPARSE_TAG_MOUNT_POINT. In the LSTAT fallback, it would check st.st_reparse_tag == IO_REPARSE_TAG_MOUNT_POINT.

It's not critical to support this since we don't have use cases for it yet in the standard library. Currently DirEntry.is_junction() is used by shutil.rmtree(), but ntpath.isjunction() is only used by pathlib.Path.is_junction().

Dominant language
Python
Stars
77.2k
Forks
36k
Avg merge
1d 9h
Merged PRs (30d)
558

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/cpython

All issues in python/cpython

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.