Skip to content

Commit 1482b99

Browse files
miss-islingtonerlend-aaslandAA-Turnerpitrou
authored
[3.11] gh-107801: Document SEEK_HOLE and SEEK_DATA (GH-107936) (#108087)
(cherry picked from commit 8a19f22) Co-authored-by: Erlend E. Aasland <[email protected]> Co-authored-by: Adam Turner <[email protected]> Co-authored-by: Antoine Pitrou <[email protected]>
1 parent b3f7ddd commit 1482b99

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

Doc/library/os.rst

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,10 @@ as internal buffering of data.
10611061
current position; :const:`SEEK_END` or ``2`` to set it relative to the end of
10621062
the file. Return the new cursor position in bytes, starting from the beginning.
10631063

1064+
.. versionchanged:: 3.3
1065+
1066+
Add support for :const:`SEEK_HOLE` and :const:`SEEK_DATA`.
1067+
10641068

10651069
.. data:: SEEK_SET
10661070
SEEK_CUR
@@ -1069,9 +1073,30 @@ as internal buffering of data.
10691073
Parameters to the :func:`lseek` function. Their values are 0, 1, and 2,
10701074
respectively.
10711075

1076+
1077+
.. data:: SEEK_HOLE
1078+
SEEK_DATA
1079+
1080+
Parameters to the :func:`lseek` function and the :meth:`~io.IOBase.seek`
1081+
method on file objects, for seeking file data and holes on sparsely
1082+
allocated files.
1083+
1084+
:data:`!SEEK_DATA`
1085+
Adjust the file offset to the next location containing data,
1086+
relative to the seek position.
1087+
1088+
:data:`!SEEK_HOLE`
1089+
Adjust the file offset to the next location containing a hole,
1090+
relative to the seek position.
1091+
A hole is defined as a sequence of zeros.
1092+
1093+
.. note::
1094+
1095+
These operations only make sense for filesystems that support them.
1096+
1097+
.. availability:: Linux >= 3.1, macOS, Unix
1098+
10721099
.. versionadded:: 3.3
1073-
Some operating systems could support additional values, like
1074-
:const:`os.SEEK_HOLE` or :const:`os.SEEK_DATA`.
10751100

10761101

10771102
.. function:: open(path, flags, mode=0o777, *, dir_fd=None)

0 commit comments

Comments
 (0)