Skip to content

Commit 8a19f22

Browse files
erlend-aaslandAA-Turnerpitrou
authored
gh-107801: Document SEEK_HOLE and SEEK_DATA (#107936)
Co-authored-by: Adam Turner <[email protected]> Co-authored-by: Antoine Pitrou <[email protected]>
1 parent 2da67a5 commit 8a19f22

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

Doc/library/os.rst

+27-2
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,10 @@ as internal buffering of data.
11711171
current position; :const:`SEEK_END` or ``2`` to set it relative to the end of
11721172
the file. Return the new cursor position in bytes, starting from the beginning.
11731173

1174+
.. versionchanged:: 3.3
1175+
1176+
Add support for :const:`SEEK_HOLE` and :const:`SEEK_DATA`.
1177+
11741178

11751179
.. data:: SEEK_SET
11761180
SEEK_CUR
@@ -1179,9 +1183,30 @@ as internal buffering of data.
11791183
Parameters to the :func:`lseek` function. Their values are 0, 1, and 2,
11801184
respectively.
11811185

1186+
1187+
.. data:: SEEK_HOLE
1188+
SEEK_DATA
1189+
1190+
Parameters to the :func:`lseek` function and the :meth:`~io.IOBase.seek`
1191+
method on file objects, for seeking file data and holes on sparsely
1192+
allocated files.
1193+
1194+
:data:`!SEEK_DATA`
1195+
Adjust the file offset to the next location containing data,
1196+
relative to the seek position.
1197+
1198+
:data:`!SEEK_HOLE`
1199+
Adjust the file offset to the next location containing a hole,
1200+
relative to the seek position.
1201+
A hole is defined as a sequence of zeros.
1202+
1203+
.. note::
1204+
1205+
These operations only make sense for filesystems that support them.
1206+
1207+
.. availability:: Linux >= 3.1, macOS, Unix
1208+
11821209
.. versionadded:: 3.3
1183-
Some operating systems could support additional values, like
1184-
:const:`os.SEEK_HOLE` or :const:`os.SEEK_DATA`.
11851210

11861211

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

0 commit comments

Comments
 (0)