-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
gh-99726: Add 'fast' argument to os.[l]stat for faster calculation #99727
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9871983
gh-99726: Add 'fast' argument to os.[l]stat for faster calculation
zooba 14ed8ef
Add fstat(fast=True) and update uses in stdlib
zooba 25b3352
Update test_inspect
zooba b37dca4
Fix NEWS quoting
zooba e8670e2
Fix tests. Update samestat docs
zooba bb71497
Update posixpath tests
zooba 2b1571e
Use correct traversal logic for non-name surrogate reparse points
zooba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#ifndef Py_INTERNAL_FILEUTILS_WINDOWS_H | ||
#define Py_INTERNAL_FILEUTILS_WINDOWS_H | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifndef Py_BUILD_CORE | ||
# error "Py_BUILD_CORE must be defined to include this header" | ||
#endif | ||
|
||
#ifdef MS_WINDOWS | ||
|
||
#if !defined(NTDDI_WIN10_NI) || !(NTDDI_VERSION >= NTDDI_WIN10_NI) | ||
typedef struct _FILE_STAT_BASIC_INFORMATION { | ||
LARGE_INTEGER FileId; | ||
LARGE_INTEGER CreationTime; | ||
LARGE_INTEGER LastAccessTime; | ||
LARGE_INTEGER LastWriteTime; | ||
LARGE_INTEGER ChangeTime; | ||
LARGE_INTEGER AllocationSize; | ||
LARGE_INTEGER EndOfFile; | ||
ULONG FileAttributes; | ||
ULONG ReparseTag; | ||
ULONG NumberOfLinks; | ||
ULONG DeviceType; | ||
ULONG DeviceCharacteristics; | ||
} FILE_STAT_BASIC_INFORMATION; | ||
|
||
typedef enum _FILE_INFO_BY_NAME_CLASS { | ||
FileStatByNameInfo, | ||
FileStatLxByNameInfo, | ||
FileCaseSensitiveByNameInfo, | ||
FileStatBasicByNameInfo, | ||
MaximumFileInfoByNameClass | ||
} FILE_INFO_BY_NAME_CLASS; | ||
#endif | ||
|
||
typedef BOOL (WINAPI *PGetFileInformationByName)( | ||
PCWSTR FileName, | ||
FILE_INFO_BY_NAME_CLASS FileInformationClass, | ||
PVOID FileInfoBuffer, | ||
ULONG FileInfoBufferSize | ||
); | ||
|
||
static inline BOOL GetFileInformationByName( | ||
PCWSTR FileName, | ||
FILE_INFO_BY_NAME_CLASS FileInformationClass, | ||
PVOID FileInfoBuffer, | ||
ULONG FileInfoBufferSize | ||
) { | ||
static PGetFileInformationByName GetFileInformationByName = NULL; | ||
static int GetFileInformationByName_init = -1; | ||
|
||
if (GetFileInformationByName_init < 0) { | ||
HMODULE hMod = LoadLibraryW(L"api-ms-win-core-file-l2-1-4"); | ||
GetFileInformationByName_init = 0; | ||
if (hMod) { | ||
GetFileInformationByName = (PGetFileInformationByName)GetProcAddress( | ||
hMod, "GetFileInformationByName"); | ||
if (GetFileInformationByName) { | ||
GetFileInformationByName_init = 1; | ||
} else { | ||
FreeLibrary(hMod); | ||
} | ||
} | ||
} | ||
|
||
if (GetFileInformationByName_init <= 0) { | ||
SetLastError(ERROR_NOT_SUPPORTED); | ||
return FALSE; | ||
} | ||
return GetFileInformationByName(FileName, FileInformationClass, FileInfoBuffer, FileInfoBufferSize); | ||
} | ||
|
||
#endif | ||
|
||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆 whoops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, no, this is correct. There's a
fast
argument to this function, which gets passed through (it just doesn't happen to make any difference right now, but that's whyfast
doesn't guarantee it'll leave out any information. Sometimes we have to take the slow path regardless, and that's the case here.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, right, I missed that :) Never mind then