GeezerVison is showing github.com — gh-83714: Use `statx` on more recent Linux to expose `st_flags` and `st_btime` on all platforms by ntninja · Pull Request #19125 · python/cpython
Conversation
ntninja
commented
Mar 23, 2020
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Still missing tests, but I'd appreciate feedback on the changes themselves in the meantime. Also ideas for properly testing btime would be appreciated.
#83714
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
jbosboom, SebAlbert, efiop, and landcaster reacted with thumbs up emoji
Uh oh!
There was an error while loading. Please reload this page.
ghost
commented
Sep 12, 2022
•
edited by ghost
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
All commit authors signed the Contributor License Agreement. 
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
On BSD/macOS this uses the value of `st_birthtime` (which remains for
compatibity reasons), on Windows it duplicates the value of `st_ctime`.
A Linux implementation is added in subsequent commits.
It cannot be enabled by default because this implementation does not have
any fallback to plain stat for older kernels and Linux 4.11 is still fairly
recent. The configure checks also ensure that the C library expose the
proper stub functions (glibc 2.28+ only).
…D UF_* equivalent as defined by FreeBSD
|
|
Use the ``statx(2)`` system call for :func:`os.stat` under Linux to provide
|
|
|
cross-platform support for btime (time of file creation) and file
|
|
|
attributes. On Windows btime is emulated using ctime and both Linux and
|
|
|
Windows file attributes are converted to their (Free)BSD equivalent were
|
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.
typo - "were" should be "where"
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
STATX_ATTR_VERITY
|
|
|
STATX_ATTR_DAX
|
|
|
|
|
|
.. versionadded:: 3.12
|
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.
tip - update version markers in docs to "next" and it'll automagically use the right version.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Could this be performance checked against the existing stat? Stat is called a lot (in Python 3.14 on linux once for every file opened which includes imports by default) and my worry is issues like https://lwn.net/Articles/944214/ where the different variants of stat have quite a bit of performance delta.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
gpshead
commented
Aug 31, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Another take on this: How about not modifying os.stat behavior at all but instead introduce an os.statx API that uses the more modern system call when available and exposes its functionality - in particular the mask functionality so that people can call it and get only the specific data they want instead of a large everything-bagel os.stat result.
The os module is all about providing wrappers around the underlying platform APIs.
(edit: raised this question on the issue)
|
cmaloney reacted with thumbs up emoji
hydrargyrum reacted with thumbs down emoji
All reactions
-
👍
1 reaction
-
👎
1 reaction
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
gpshead
changed the title
bpo-39533: Use statx on more recent Linux to expose st_flags and st_btime on all platforms
gh-83714: Use statx on more recent Linux to expose st_flags and st_btime on all platforms
Aug 31, 2025
Another take on this: How about not modifying os.stat behavior at all but instead introduce an os.statx API that uses the more modern system call when available and exposes its functionality - in particular the mask functionality so that people can call it and get only the specific data they want instead of a large everything-bagel os.stat result.
os.statx() has been added. This PR is now outdated, I close it. There is a discussion on using os.statx() in pathlib.
|
cmaloney reacted with hooray emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks @ntninja for your contribution even if it was taken as it is. Exposing new syscalls is non trivial, it takes time to decide how to expose it in Python.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
gpshead
gpshead approved these changes
+2 more reviewers
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|