chunk_id stringlengths 36 36 | source stringclasses 35
values | source_url stringlengths 0 290 | upstream_license stringclasses 1
value | document_id stringlengths 36 36 | chunk_index int64 0 324k | retrieved_at stringclasses 2
values | chunker_version stringclasses 4
values | content_hash stringlengths 15 64 | content stringlengths 50 44.7k | namespace stringclasses 9
values | source_name stringclasses 35
values | raw_text stringlengths 50 44.7k | cleaned_text stringlengths 50 44.7k | tags stringclasses 49
values | collection_name stringclasses 11
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cfd471b0-62ff-4c54-845d-7b93cd5d2a17 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,306 | supabase-export-v2 | c853894961153b60 | >>> r = RECT(POINT(1, 2), POINT(3, 4)) >>> r = RECT((1, 2), (3, 4))
Field :term:`descriptor`\s can be retrieved from the *class*, they are useful
for debugging because they can provide useful information. See :class:`CField`:: | trusted_official_docs | CPython Docs | >>> r = RECT(POINT(1, 2), POINT(3, 4)) >>> r = RECT((1, 2), (3, 4))
Field :term:`descriptor`\s can be retrieved from the *class*, they are useful
for debugging because they can provide useful information. See :class:`CField`:: | >>> r = RECT(POINT(1, 2), POINT(3, 4)) >>> r = RECT((1, 2), (3, 4))
Field :term:`descriptor`\s can be retrieved from the *class*, they are useful
for debugging because they can provide useful information. See :class:`CField`:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d00690d0-e073-4d38-b2b6-99d91a8c4f88 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,190 | supabase-export-v2 | e84176b77e0d6f9c | assumes the functions return a Windows :c:type:`!HRESULT` error code. The error code is used to automatically raise an :class:`OSError` exception when the function call fails.
.. versionchanged:: 3.3
Windows errors used to raise :exc:`WindowsError`, which is now an alias
of :exc:`OSError`. | trusted_official_docs | CPython Docs | assumes the functions return a Windows :c:type:`!HRESULT` error code. The error code is used to automatically raise an :class:`OSError` exception when the function call fails.
.. versionchanged:: 3.3
Windows errors used to raise :exc:`WindowsError`, which is now an alias
of :exc:`OSError`. | assumes the functions return a Windows :c:type:`!HRESULT` error code. The error code is used to automatically raise an :class:`OSError` exception when the function call fails.
.. versionchanged:: 3.3
Windows errors used to raise :exc:`WindowsError`, which is now an alias
of :exc:`OSError`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d1111705-5cc5-40c6-a04e-dd73d9589d80 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,517 | supabase-export-v2 | 52362fd51a7426e4 | Loading a library through any of these objects raises an :ref:`auditing event <auditing>` ``ctypes.dlopen`` with string argument ``name``, the name used to load the library.
.. audit-event:: ctypes.dlsym library,name ctypes.LibraryLoader | trusted_official_docs | CPython Docs | Loading a library through any of these objects raises an :ref:`auditing event <auditing>` ``ctypes.dlopen`` with string argument ``name``, the name used to load the library.
.. audit-event:: ctypes.dlsym library,name ctypes.LibraryLoader | Loading a library through any of these objects raises an :ref:`auditing event <auditing>` ``ctypes.dlopen`` with string argument ``name``, the name used to load the library.
.. audit-event:: ctypes.dlsym library,name ctypes.LibraryLoader | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d1a75808-2137-4248-a8a2-e08624af2bbd | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,285 | supabase-export-v2 | 5b2b5b8bb064f40b | .. doctest::
>>> strchr.restype = c_char_p
>>> strchr.argtypes = [c_char_p, c_char]
>>> strchr(b"abcdef", b"d")
b'def'
>>> strchr(b"abcdef", b"def")
Traceback (most recent call last):
ctypes.ArgumentError: argument 2: TypeError: one character bytes, bytearray or integer expected
>>> print(strchr(b"abcdef", b"x")... | trusted_official_docs | CPython Docs | .. doctest::
>>> strchr.restype = c_char_p
>>> strchr.argtypes = [c_char_p, c_char]
>>> strchr(b"abcdef", b"d")
b'def'
>>> strchr(b"abcdef", b"def")
Traceback (most recent call last):
ctypes.ArgumentError: argument 2: TypeError: one character bytes, bytearray or integer expected
>>> print(strchr(b"abcdef", b"x")... | .. doctest::
>>> strchr.restype = c_char_p
>>> strchr.argtypes = [c_char_p, c_char]
>>> strchr(b"abcdef", b"d")
b'def'
>>> strchr(b"abcdef", b"def")
Traceback (most recent call last):
ctypes.ArgumentError: argument 2: TypeError: one character bytes, bytearray or integer expected
>>> print(strchr(b"abcdef", b"x")... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d1cc3bb2-2101-4685-847c-bcdbf94cd753 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,442 | supabase-export-v2 | d2f45846ea5514ab | :mod:`!ctypes` provides some support for variable-sized arrays and structures.
The :func:`resize` function can be used to resize the memory buffer of an
existing ctypes object. The function takes the object as first argument, and
the requested size in bytes as the second argument. The memory block cannot be
made smalle... | trusted_official_docs | CPython Docs | :mod:`!ctypes` provides some support for variable-sized arrays and structures.
The :func:`resize` function can be used to resize the memory buffer of an
existing ctypes object. The function takes the object as first argument, and
the requested size in bytes as the second argument. The memory block cannot be
made smalle... | :mod:`!ctypes` provides some support for variable-sized arrays and structures.
The :func:`resize` function can be used to resize the memory buffer of an
existing ctypes object. The function takes the object as first argument, and
the requested size in bytes as the second argument. The memory block cannot be
made smalle... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d1fa8646-692b-4171-a1fd-bce475c6c499 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,733 | supabase-export-v2 | 84fe1ef5ebba8b55 | .. method:: from_param(obj)
This method adapts *obj* to a ctypes type. It is called with the actual
object used in a foreign function call when the type is present in the
foreign function's :attr:`~_CFuncPtr.argtypes` tuple;
it must return an object that can be used as a function call parameter. | trusted_official_docs | CPython Docs | .. method:: from_param(obj)
This method adapts *obj* to a ctypes type. It is called with the actual
object used in a foreign function call when the type is present in the
foreign function's :attr:`~_CFuncPtr.argtypes` tuple;
it must return an object that can be used as a function call parameter. | .. method:: from_param(obj)
This method adapts *obj* to a ctypes type. It is called with the actual
object used in a foreign function call when the type is present in the
foreign function's :attr:`~_CFuncPtr.argtypes` tuple;
it must return an object that can be used as a function call parameter. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d235f397-194f-4847-af30-ba4bbe644088 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,396 | supabase-export-v2 | b9aaaddbf5297e42 | must return a negative integer if the first item is smaller than the second, a zero if they are equal, and a positive integer otherwise.
So our callback function receives pointers to integers, and must return an
integer. First we create the ``type`` for the callback function:: | trusted_official_docs | CPython Docs | must return a negative integer if the first item is smaller than the second, a zero if they are equal, and a positive integer otherwise.
So our callback function receives pointers to integers, and must return an
integer. First we create the ``type`` for the callback function:: | must return a negative integer if the first item is smaller than the second, a zero if they are equal, and a positive integer otherwise.
So our callback function receives pointers to integers, and must return an
integer. First we create the ``type`` for the callback function:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d412d931-a75e-44ca-a5fe-caf4f15d28cc | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,610 | supabase-export-v2 | 98dd29f1ba821e56 | The optional third item is the default value for this parameter.
The following example demonstrates how to wrap the Windows ``MessageBoxW`` function so
that it supports default parameters and named arguments. The C declaration from
the windows header file is this:: | trusted_official_docs | CPython Docs | The optional third item is the default value for this parameter.
The following example demonstrates how to wrap the Windows ``MessageBoxW`` function so
that it supports default parameters and named arguments. The C declaration from
the windows header file is this:: | The optional third item is the default value for this parameter.
The following example demonstrates how to wrap the Windows ``MessageBoxW`` function so
that it supports default parameters and named arguments. The C declaration from
the windows header file is this:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d4835570-ba44-4db6-9910-afcbc8dfeb7f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,465 | supabase-export-v2 | eb1b473107264666 | library is loaded. For details, consult the :manpage:`dlopen(3)` manpage. On Windows, *mode* is ignored. On posix systems, RTLD_NOW is always added, and is not configurable.
The *use_errno* parameter, when set to true, enables a ctypes mechanism that
allows accessing the system :data:`errno` error number in a safe way... | trusted_official_docs | CPython Docs | library is loaded. For details, consult the :manpage:`dlopen(3)` manpage. On Windows, *mode* is ignored. On posix systems, RTLD_NOW is always added, and is not configurable.
The *use_errno* parameter, when set to true, enables a ctypes mechanism that
allows accessing the system :data:`errno` error number in a safe way... | library is loaded. For details, consult the :manpage:`dlopen(3)` manpage. On Windows, *mode* is ignored. On posix systems, RTLD_NOW is always added, and is not configurable.
The *use_errno* parameter, when set to true, enables a ctypes mechanism that
allows accessing the system :data:`errno` error number in a safe way... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d5531588-16fb-4207-a4ac-5d72943a6821 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,822 | supabase-export-v2 | d371209dd875b9ad | .. class:: c_ulonglong
Represents the C :c:expr:`unsigned long long` datatype. The constructor
accepts an optional integer initializer; no overflow checking is done. On platforms where ``sizeof(long long) == sizeof(long)`` it is an alias
to :class:`c_long`. | trusted_official_docs | CPython Docs | .. class:: c_ulonglong
Represents the C :c:expr:`unsigned long long` datatype. The constructor
accepts an optional integer initializer; no overflow checking is done. On platforms where ``sizeof(long long) == sizeof(long)`` it is an alias
to :class:`c_long`. | .. class:: c_ulonglong
Represents the C :c:expr:`unsigned long long` datatype. The constructor
accepts an optional integer initializer; no overflow checking is done. On platforms where ``sizeof(long long) == sizeof(long)`` it is an alias
to :class:`c_long`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d5b3fa08-59ad-4a4b-a96a-226064dc3252 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,649 | supabase-export-v2 | 0ff5fb395d5223a7 | If *size* is not given (or if it is ``None``), the buffer is made one element larger than *init*, effectively adding a NUL terminator.
If both arguments are given, *size* must not be less than ``len(init)``. | trusted_official_docs | CPython Docs | If *size* is not given (or if it is ``None``), the buffer is made one element larger than *init*, effectively adding a NUL terminator.
If both arguments are given, *size* must not be less than ``len(init)``. | If *size* is not given (or if it is ``None``), the buffer is made one element larger than *init*, effectively adding a NUL terminator.
If both arguments are given, *size* must not be less than ``len(init)``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d5cf8476-66a1-4256-86bc-1e3f736a7143 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,534 | supabase-export-v2 | 13b84cc2f07a2257 | file. If the output of these programs does not correspond to the dynamic linker used by Python, the result of this function may be misleading.
.. versionchanged:: 3.6
On Linux, the value of the environment variable ``LD_LIBRARY_PATH`` is used
when searching for libraries, if a library cannot be found by any other mea... | trusted_official_docs | CPython Docs | file. If the output of these programs does not correspond to the dynamic linker used by Python, the result of this function may be misleading.
.. versionchanged:: 3.6
On Linux, the value of the environment variable ``LD_LIBRARY_PATH`` is used
when searching for libraries, if a library cannot be found by any other mea... | file. If the output of these programs does not correspond to the dynamic linker used by Python, the result of this function may be misleading.
.. versionchanged:: 3.6
On Linux, the value of the environment variable ``LD_LIBRARY_PATH`` is used
when searching for libraries, if a library cannot be found by any other mea... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d5d4b1e0-4f5c-4953-9f7d-9877b3c0304d | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,372 | supabase-export-v2 | 19e986e582876b7e | For these cases, the :func:`cast` function is handy.
The :func:`cast` function can be used to cast a ctypes instance into a pointer
to a different ctypes data type. :func:`cast` takes two parameters, a ctypes
object that is or can be converted to a pointer of some kind, and a ctypes
pointer type. It returns an instance... | trusted_official_docs | CPython Docs | For these cases, the :func:`cast` function is handy.
The :func:`cast` function can be used to cast a ctypes instance into a pointer
to a different ctypes data type. :func:`cast` takes two parameters, a ctypes
object that is or can be converted to a pointer of some kind, and a ctypes
pointer type. It returns an instance... | For these cases, the :func:`cast` function is handy.
The :func:`cast` function can be used to cast a ctypes instance into a pointer
to a different ctypes data type. :func:`cast` takes two parameters, a ctypes
object that is or can be converted to a pointer of some kind, and a ctypes
pointer type. It returns an instance... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d617081d-1d77-48f5-a45f-905b46bbfb2b | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,922 | supabase-export-v2 | a5d45970079e5f4f | To get the field's value, read the storage unit as an integer, :ref:`shift left <shifting>` by :attr:`!bit_offset` and take the :attr:`!bit_size` least significant bits.
For non-bitfields, :attr:`!bit_offset` is zero
and :attr:`!bit_size` is equal to ``byte_size * 8``. | trusted_official_docs | CPython Docs | To get the field's value, read the storage unit as an integer, :ref:`shift left <shifting>` by :attr:`!bit_offset` and take the :attr:`!bit_size` least significant bits.
For non-bitfields, :attr:`!bit_offset` is zero
and :attr:`!bit_size` is equal to ``byte_size * 8``. | To get the field's value, read the storage unit as an integer, :ref:`shift left <shifting>` by :attr:`!bit_offset` and take the :attr:`!bit_size` least significant bits.
For non-bitfields, :attr:`!bit_offset` is zero
and :attr:`!bit_size` is equal to ``byte_size * 8``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d6ba9125-da58-4f1d-8704-c01715e6422f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,445 | supabase-export-v2 | 7bd7c8f9ce715878 | would one access the additional elements contained in this array? Since the type still only knows about 4 elements, we get errors accessing other elements::
>>> short_array[:]
[0, 0, 0, 0]
>>> short_array[7]
Traceback (most recent call last):
... IndexError: invalid index
>>> | trusted_official_docs | CPython Docs | would one access the additional elements contained in this array? Since the type still only knows about 4 elements, we get errors accessing other elements::
>>> short_array[:]
[0, 0, 0, 0]
>>> short_array[7]
Traceback (most recent call last):
... IndexError: invalid index
>>> | would one access the additional elements contained in this array? Since the type still only knows about 4 elements, we get errors accessing other elements::
>>> short_array[:]
[0, 0, 0, 0]
>>> short_array[7]
Traceback (most recent call last):
... IndexError: invalid index
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d89750e8-eda1-48e3-8ca6-4c2afcb998ed | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,313 | supabase-export-v2 | 74c7e44737fee6e3 | it. It is possible to override this behavior entirely by specifying a :attr:`~Structure._layout_` class attribute in the subclass definition; see the attribute documentation for details.
It is possible to specify the maximum alignment for the fields and/or for the
structure itself by setting the class attributes :attr:... | trusted_official_docs | CPython Docs | it. It is possible to override this behavior entirely by specifying a :attr:`~Structure._layout_` class attribute in the subclass definition; see the attribute documentation for details.
It is possible to specify the maximum alignment for the fields and/or for the
structure itself by setting the class attributes :attr:... | it. It is possible to override this behavior entirely by specifying a :attr:`~Structure._layout_` class attribute in the subclass definition; see the attribute documentation for details.
It is possible to specify the maximum alignment for the fields and/or for the
structure itself by setting the class attributes :attr:... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d96dbbd6-da82-44fc-8abd-81bf770efe80 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,619 | supabase-export-v2 | fbbdfbeb3c4835fe | Here is the wrapping with :mod:`!ctypes`::
>>> from ctypes import POINTER, WINFUNCTYPE, windll, WinError
>>> from ctypes.wintypes import BOOL, HWND, RECT
>>> prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT))
>>> paramflags = (1, "hwnd"), (2, "lprect")
>>> GetWindowRect = prototype(("GetWindowRect", windll.user32),... | trusted_official_docs | CPython Docs | Here is the wrapping with :mod:`!ctypes`::
>>> from ctypes import POINTER, WINFUNCTYPE, windll, WinError
>>> from ctypes.wintypes import BOOL, HWND, RECT
>>> prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT))
>>> paramflags = (1, "hwnd"), (2, "lprect")
>>> GetWindowRect = prototype(("GetWindowRect", windll.user32),... | Here is the wrapping with :mod:`!ctypes`::
>>> from ctypes import POINTER, WINFUNCTYPE, windll, WinError
>>> from ctypes.wintypes import BOOL, HWND, RECT
>>> prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT))
>>> paramflags = (1, "hwnd"), (2, "lprect")
>>> GetWindowRect = prototype(("GetWindowRect", windll.user32),... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d9905eb6-4aa4-4fa7-85ed-2a42bdfcda0f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,596 | supabase-export-v2 | a82534ad21d7d39e | name of the exported function as string, or the ordinal of the exported function as small integer. The second item is the shared library instance.
.. function:: prototype(vtbl_index, name[, paramflags[, iid]])
:noindex:
:module: | trusted_official_docs | CPython Docs | name of the exported function as string, or the ordinal of the exported function as small integer. The second item is the shared library instance.
.. function:: prototype(vtbl_index, name[, paramflags[, iid]])
:noindex:
:module: | name of the exported function as string, or the ordinal of the exported function as small integer. The second item is the shared library instance.
.. function:: prototype(vtbl_index, name[, paramflags[, iid]])
:noindex:
:module: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d994fb94-e144-4427-943c-c7c2479f2741 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,585 | supabase-export-v2 | 6b68028a0ca190f9 | .. function:: WINFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
The returned function prototype creates functions that use the
``stdcall`` calling convention. The function will
release the GIL during the call. *use_errno* and *use_last_error* have the
same meaning as above. | trusted_official_docs | CPython Docs | .. function:: WINFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
The returned function prototype creates functions that use the
``stdcall`` calling convention. The function will
release the GIL during the call. *use_errno* and *use_last_error* have the
same meaning as above. | .. function:: WINFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
The returned function prototype creates functions that use the
``stdcall`` calling convention. The function will
release the GIL during the call. *use_errno* and *use_last_error* have the
same meaning as above. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
da2dc74a-b7f4-4330-b7e9-f3f4c49241ff | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,872 | supabase-export-v2 | 4e3680079aba0692 | a positive power of two. The effect is equivalent to ``#pragma pack(N)`` in C, except :mod:`!ctypes` may allow larger *n* than what the compiler accepts.
:attr:`!_pack_` must already be defined
when :attr:`_fields_` is assigned, otherwise it will have no effect. | trusted_official_docs | CPython Docs | a positive power of two. The effect is equivalent to ``#pragma pack(N)`` in C, except :mod:`!ctypes` may allow larger *n* than what the compiler accepts.
:attr:`!_pack_` must already be defined
when :attr:`_fields_` is assigned, otherwise it will have no effect. | a positive power of two. The effect is equivalent to ``#pragma pack(N)`` in C, except :mod:`!ctypes` may allow larger *n* than what the compiler accepts.
:attr:`!_pack_` must already be defined
when :attr:`_fields_` is assigned, otherwise it will have no effect. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dd571f3a-e1d8-4360-93d3-450a77569874 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,312 | supabase-export-v2 | ac80e131ab4778b3 | Structure/union layout, alignment and byte order ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
By default, Structure and Union fields are laid out in the same way the C
compiler does it. It is possible to override this behavior entirely by specifying a
:attr:`~Structure._layout_` class attribute in the subclass defi... | trusted_official_docs | CPython Docs | Structure/union layout, alignment and byte order ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
By default, Structure and Union fields are laid out in the same way the C
compiler does it. It is possible to override this behavior entirely by specifying a
:attr:`~Structure._layout_` class attribute in the subclass defi... | Structure/union layout, alignment and byte order ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
By default, Structure and Union fields are laid out in the same way the C
compiler does it. It is possible to override this behavior entirely by specifying a
:attr:`~Structure._layout_` class attribute in the subclass defi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dd8199f6-6bea-4b31-b2fe-a8cd098b6574 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,244 | supabase-export-v2 | 18f1c31c690c99cd | p = create_string_buffer(b"Hello", 10) # create a 10 byte buffer >>> print(sizeof(p), repr(p.raw)) 10 b'Hello\x00\x00\x00\x00\x00' >>> p.value = b"Hi" >>> print(sizeof(p), repr(p.raw)) 10 b'Hi\x00lo\x00\x00\x00\x00\x00' >>>
The :func:`create_string_buffer` function replaces the old :func:`!c_buffer`
function (which is ... | trusted_official_docs | CPython Docs | p = create_string_buffer(b"Hello", 10) # create a 10 byte buffer >>> print(sizeof(p), repr(p.raw)) 10 b'Hello\x00\x00\x00\x00\x00' >>> p.value = b"Hi" >>> print(sizeof(p), repr(p.raw)) 10 b'Hi\x00lo\x00\x00\x00\x00\x00' >>>
The :func:`create_string_buffer` function replaces the old :func:`!c_buffer`
function (which is ... | p = create_string_buffer(b"Hello", 10) # create a 10 byte buffer >>> print(sizeof(p), repr(p.raw)) 10 b'Hello\x00\x00\x00\x00\x00' >>> p.value = b"Hi" >>> print(sizeof(p), repr(p.raw)) 10 b'Hi\x00lo\x00\x00\x00\x00\x00' >>>
The :func:`create_string_buffer` function replaces the old :func:`!c_buffer`
function (which is ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ddbf4ed3-3ce0-4ee9-9c9d-f8083c61667e | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,236 | supabase-export-v2 | 4cf517f1d7ab2333 | >>> c_int() c_long(0) >>> c_wchar_p("Hello, World") c_wchar_p(140018365411392) >>> c_ushort(-3) c_ushort(65533) >>>
The constructors for numeric types will convert input using
:py:meth:`~object.__bool__`,
:py:meth:`~object.__index__` (for ``int``),
:py:meth:`~object.__float__` or :py:meth:`~object.__complex__`. This me... | trusted_official_docs | CPython Docs | >>> c_int() c_long(0) >>> c_wchar_p("Hello, World") c_wchar_p(140018365411392) >>> c_ushort(-3) c_ushort(65533) >>>
The constructors for numeric types will convert input using
:py:meth:`~object.__bool__`,
:py:meth:`~object.__index__` (for ``int``),
:py:meth:`~object.__float__` or :py:meth:`~object.__complex__`. This me... | >>> c_int() c_long(0) >>> c_wchar_p("Hello, World") c_wchar_p(140018365411392) >>> c_ushort(-3) c_ushort(65533) >>>
The constructors for numeric types will convert input using
:py:meth:`~object.__bool__`,
:py:meth:`~object.__index__` (for ``int``),
:py:meth:`~object.__float__` or :py:meth:`~object.__complex__`. This me... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ddeee332-f87c-4e43-891e-a73924996145 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,205 | supabase-export-v2 | 994ec8775087284a | has the following C prototype, and a macro is used to expose one of them as ``GetModuleHandle`` depending on whether UNICODE is defined or not::
/* ANSI version */
HMODULE GetModuleHandleA(LPCSTR lpModuleName);
/* UNICODE version */
HMODULE GetModuleHandleW(LPCWSTR lpModuleName); | trusted_official_docs | CPython Docs | has the following C prototype, and a macro is used to expose one of them as ``GetModuleHandle`` depending on whether UNICODE is defined or not::
/* ANSI version */
HMODULE GetModuleHandleA(LPCSTR lpModuleName);
/* UNICODE version */
HMODULE GetModuleHandleW(LPCWSTR lpModuleName); | has the following C prototype, and a macro is used to expose one of them as ``GetModuleHandle`` depending on whether UNICODE is defined or not::
/* ANSI version */
HMODULE GetModuleHandleA(LPCSTR lpModuleName);
/* UNICODE version */
HMODULE GetModuleHandleW(LPCWSTR lpModuleName); | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ddf4695f-4d88-4948-a878-65ac61530462 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,242 | supabase-export-v2 | d4621ff0ce5b8aab | "Hi, there" >>> print(c_s) # the memory location has changed c_wchar_p(139966783348904) >>> print(c_s.value) Hi, there >>> print(s) # first object is unchanged Hello, World >>>
You should be careful, however, not to pass them to functions expecting pointers
to mutable memory. If you need mutable memory blocks, ctypes h... | trusted_official_docs | CPython Docs | "Hi, there" >>> print(c_s) # the memory location has changed c_wchar_p(139966783348904) >>> print(c_s.value) Hi, there >>> print(s) # first object is unchanged Hello, World >>>
You should be careful, however, not to pass them to functions expecting pointers
to mutable memory. If you need mutable memory blocks, ctypes h... | "Hi, there" >>> print(c_s) # the memory location has changed c_wchar_p(139966783348904) >>> print(c_s.value) Hi, there >>> print(s) # first object is unchanged Hello, World >>>
You should be careful, however, not to pass them to functions expecting pointers
to mutable memory. If you need mutable memory blocks, ctypes h... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
de67a7b4-608e-4d84-b694-4696e0e6d1c8 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,624 | supabase-export-v2 | ebe3d4bfb7fa3ab8 | instead of a ``RECT`` instance, you can retrieve the fields in the function and return them instead, the normal processing will no longer take place::
>>> def errcheck(result, func, args):
... if not result:
... raise WinError()
... rc = args[1]
... return rc.left, rc.top, rc.bottom, rc.right
... >>> GetWindowRect... | trusted_official_docs | CPython Docs | instead of a ``RECT`` instance, you can retrieve the fields in the function and return them instead, the normal processing will no longer take place::
>>> def errcheck(result, func, args):
... if not result:
... raise WinError()
... rc = args[1]
... return rc.left, rc.top, rc.bottom, rc.right
... >>> GetWindowRect... | instead of a ``RECT`` instance, you can retrieve the fields in the function and return them instead, the normal processing will no longer take place::
>>> def errcheck(result, func, args):
... if not result:
... raise WinError()
... rc = args[1]
... return rc.left, rc.top, rc.bottom, rc.right
... >>> GetWindowRect... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dff79b69-0b85-4a2a-81a9-c6b6ae7b1a27 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,317 | supabase-export-v2 | 23218aff891dff9a | Bit fields in structures and unions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It is possible to create structures and unions containing bit fields. Bit fields
are only possible for integer fields, the bit width is specified as the third
item in the :attr:`~Structure._fields_` tuples:: | trusted_official_docs | CPython Docs | Bit fields in structures and unions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It is possible to create structures and unions containing bit fields. Bit fields
are only possible for integer fields, the bit width is specified as the third
item in the :attr:`~Structure._fields_` tuples:: | Bit fields in structures and unions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It is possible to create structures and unions containing bit fields. Bit fields
are only possible for integer fields, the bit width is specified as the third
item in the :attr:`~Structure._fields_` tuples:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e095b4d7-9cb9-45f5-b72e-5162d0664cd1 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,250 | supabase-export-v2 | 9df9bdbbb56f12af | strings, and bytes objects have to be wrapped in their corresponding :mod:`!ctypes` type, so that they can be converted to the required C data type::
>>> printf(b"An int %d, a double %f\n", 1234, c_double(3.14))
An int 1234, a double 3.140000
31
>>> | trusted_official_docs | CPython Docs | strings, and bytes objects have to be wrapped in their corresponding :mod:`!ctypes` type, so that they can be converted to the required C data type::
>>> printf(b"An int %d, a double %f\n", 1234, c_double(3.14))
An int 1234, a double 3.140000
31
>>> | strings, and bytes objects have to be wrapped in their corresponding :mod:`!ctypes` type, so that they can be converted to the required C data type::
>>> printf(b"An int %d, a double %f\n", 1234, c_double(3.14))
An int 1234, a double 3.140000
31
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e316e245-ce97-43e7-8a08-7cf5459ac1a9 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,573 | supabase-export-v2 | 400b9426e3592bdb | *func* is the foreign function object itself, this allows reusing the same callable object to check or post process the results of several functions.
*arguments* is a tuple containing the parameters originally passed to
the function call, this allows specializing the behavior on the
arguments used. | trusted_official_docs | CPython Docs | *func* is the foreign function object itself, this allows reusing the same callable object to check or post process the results of several functions.
*arguments* is a tuple containing the parameters originally passed to
the function call, this allows specializing the behavior on the
arguments used. | *func* is the foreign function object itself, this allows reusing the same callable object to check or post process the results of several functions.
*arguments* is a tuple containing the parameters originally passed to
the function call, this allows specializing the behavior on the
arguments used. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e43f704b-f05d-4d31-8926-22b6be244827 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,435 | supabase-export-v2 | a6fbf05a46095deb | Another example that may behave differently from what one would expect is this::
>>> s = c_char_p()
>>> s.value = b"abc def ghi"
>>> s.value
b'abc def ghi'
>>> s.value is s.value
False
>>> | trusted_official_docs | CPython Docs | Another example that may behave differently from what one would expect is this::
>>> s = c_char_p()
>>> s.value = b"abc def ghi"
>>> s.value
b'abc def ghi'
>>> s.value is s.value
False
>>> | Another example that may behave differently from what one would expect is this::
>>> s = c_char_p()
>>> s.value = b"abc def ghi"
>>> s.value
b'abc def ghi'
>>> s.value is s.value
False
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e5016744-b92e-4568-9631-e57a94b72a06 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,771 | supabase-export-v2 | ec95b77b2e471ed2 | .. class:: c_char_p
Represents the C :c:expr:`char *` datatype when it points to a zero-terminated
string. For a general character pointer that may also point to binary data,
``POINTER(c_char)`` must be used. The constructor accepts an integer
address, or a bytes object. | trusted_official_docs | CPython Docs | .. class:: c_char_p
Represents the C :c:expr:`char *` datatype when it points to a zero-terminated
string. For a general character pointer that may also point to binary data,
``POINTER(c_char)`` must be used. The constructor accepts an integer
address, or a bytes object. | .. class:: c_char_p
Represents the C :c:expr:`char *` datatype when it points to a zero-terminated
string. For a general character pointer that may also point to binary data,
``POINTER(c_char)`` must be used. The constructor accepts an integer
address, or a bytes object. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e5d7ec46-825b-41f3-ab4f-596670d037f3 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,294 | supabase-export-v2 | 39e43662c0fccfa4 | work since it constructs a real pointer object, so it is faster to use :func:`byref` if you don't need the pointer object in Python itself::
>>> i = c_int()
>>> f = c_float()
>>> s = create_string_buffer(b'\000' * 32)
>>> print(i.value, f.value, repr(s.value))
0 0.0 b''
>>> libc.sscanf(b"1 3.14 Hello", b"%d %f %s"... | trusted_official_docs | CPython Docs | work since it constructs a real pointer object, so it is faster to use :func:`byref` if you don't need the pointer object in Python itself::
>>> i = c_int()
>>> f = c_float()
>>> s = create_string_buffer(b'\000' * 32)
>>> print(i.value, f.value, repr(s.value))
0 0.0 b''
>>> libc.sscanf(b"1 3.14 Hello", b"%d %f %s"... | work since it constructs a real pointer object, so it is faster to use :func:`byref` if you don't need the pointer object in Python itself::
>>> i = c_int()
>>> f = c_float()
>>> s = create_string_buffer(b'\000' * 32)
>>> print(i.value, f.value, repr(s.value))
0 0.0 b''
>>> libc.sscanf(b"1 3.14 Hello", b"%d %f %s"... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e63a0756-ad08-4ca0-83a9-5511506090f2 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,648 | supabase-export-v2 | 0939883a1c037240 | argument is given, it must be :class:`bytes`. It is used to initialize the array items. Bytes not initialized this way are set to zero (NUL).
If *size* is not given (or if it is ``None``), the buffer is made one element
larger than *init*, effectively adding a NUL terminator. | trusted_official_docs | CPython Docs | argument is given, it must be :class:`bytes`. It is used to initialize the array items. Bytes not initialized this way are set to zero (NUL).
If *size* is not given (or if it is ``None``), the buffer is made one element
larger than *init*, effectively adding a NUL terminator. | argument is given, it must be :class:`bytes`. It is used to initialize the array items. Bytes not initialized this way are set to zero (NUL).
If *size* is not given (or if it is ``None``), the buffer is made one element
larger than *init*, effectively adding a NUL terminator. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e6cdaf0f-b018-46bd-a50c-e25a5619d647 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,446 | supabase-export-v2 | a55f4a09ddd3210f | >>> short_array[:] [0, 0, 0, 0] >>> short_array[7] Traceback (most recent call last): ... IndexError: invalid index >>>
Another way to use variable-sized data types with :mod:`!ctypes` is to use the
dynamic nature of Python, and (re-)define the data type after the required size
is already known, on a case by case basis... | trusted_official_docs | CPython Docs | >>> short_array[:] [0, 0, 0, 0] >>> short_array[7] Traceback (most recent call last): ... IndexError: invalid index >>>
Another way to use variable-sized data types with :mod:`!ctypes` is to use the
dynamic nature of Python, and (re-)define the data type after the required size
is already known, on a case by case basis... | >>> short_array[:] [0, 0, 0, 0] >>> short_array[7] Traceback (most recent call last): ... IndexError: invalid index >>>
Another way to use variable-sized data types with :mod:`!ctypes` is to use the
dynamic nature of Python, and (re-)define the data type after the required size
is already known, on a case by case basis... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e6ef84e9-8d82-4032-a922-3113076153d9 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,613 | supabase-export-v2 | 2977f200eebac74d | Here is the wrapping with :mod:`!ctypes`::
>>> from ctypes import c_int, WINFUNCTYPE, windll
>>> from ctypes.wintypes import HWND, LPCWSTR, UINT
>>> prototype = WINFUNCTYPE(c_int, HWND, LPCWSTR, LPCWSTR, UINT)
>>> paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", "Hello from ctypes"), (1, "flags", 0)
>... | trusted_official_docs | CPython Docs | Here is the wrapping with :mod:`!ctypes`::
>>> from ctypes import c_int, WINFUNCTYPE, windll
>>> from ctypes.wintypes import HWND, LPCWSTR, UINT
>>> prototype = WINFUNCTYPE(c_int, HWND, LPCWSTR, LPCWSTR, UINT)
>>> paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", "Hello from ctypes"), (1, "flags", 0)
>... | Here is the wrapping with :mod:`!ctypes`::
>>> from ctypes import c_int, WINFUNCTYPE, windll
>>> from ctypes.wintypes import HWND, LPCWSTR, UINT
>>> prototype = WINFUNCTYPE(c_int, HWND, LPCWSTR, LPCWSTR, UINT)
>>> paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", "Hello from ctypes"), (1, "flags", 0)
>... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e710dcd6-87e7-4b08-9f4d-4331030be94f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,477 | supabase-export-v2 | 18aea59a894fc519 | >>> from ctypes import CDLL >>> libc = CDLL("libc.so.6") # On Linux >>> libc.time == libc.time True >>> libc['time'] == libc['time'] False
The following public attributes are available. Their name starts with an
underscore to not clash with exported function names: | trusted_official_docs | CPython Docs | >>> from ctypes import CDLL >>> libc = CDLL("libc.so.6") # On Linux >>> libc.time == libc.time True >>> libc['time'] == libc['time'] False
The following public attributes are available. Their name starts with an
underscore to not clash with exported function names: | >>> from ctypes import CDLL >>> libc = CDLL("libc.so.6") # On Linux >>> libc.time == libc.time True >>> libc['time'] == libc['time'] False
The following public attributes are available. Their name starts with an
underscore to not clash with exported function names: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e8c681f8-7732-4528-8c63-43126770243c | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,880 | supabase-export-v2 | 72d573430d56f606 | Using values that are not powers of two is discouraged and may lead to surprising behavior.
:attr:`!_align_` must already be defined
when :attr:`_fields_` is assigned, otherwise it will have no effect. | trusted_official_docs | CPython Docs | Using values that are not powers of two is discouraged and may lead to surprising behavior.
:attr:`!_align_` must already be defined
when :attr:`_fields_` is assigned, otherwise it will have no effect. | Using values that are not powers of two is discouraged and may lead to surprising behavior.
:attr:`!_align_` must already be defined
when :attr:`_fields_` is assigned, otherwise it will have no effect. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ea699b4c-c1ed-474d-951c-6d69d22583b4 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,262 | supabase-export-v2 | 21a8935827b6614c | ... def __init__(self, number): ... self._as_parameter_ = number ... >>> bottles = Bottles(42) >>> printf(b"%d bottles of beer\n", bottles) 42 bottles of beer 19 >>>
If you don't want to store the instance's data in the :attr:`!_as_parameter_`
instance variable, you could define a :class:`property` which makes the
attr... | trusted_official_docs | CPython Docs | ... def __init__(self, number): ... self._as_parameter_ = number ... >>> bottles = Bottles(42) >>> printf(b"%d bottles of beer\n", bottles) 42 bottles of beer 19 >>>
If you don't want to store the instance's data in the :attr:`!_as_parameter_`
instance variable, you could define a :class:`property` which makes the
attr... | ... def __init__(self, number): ... self._as_parameter_ = number ... >>> bottles = Bottles(42) >>> printf(b"%d bottles of beer\n", bottles) 42 bottles of beer 19 >>>
If you don't want to store the instance's data in the :attr:`!_as_parameter_`
instance variable, you could define a :class:`property` which makes the
attr... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
eb9929a6-e6fb-472c-a186-a8e0fd2e6050 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,346 | supabase-export-v2 | 07aa9cd35be69f6f | if you receive a pointer from a C function, and you *know* that the pointer actually points to an array instead of a single item.
Behind the scenes, the :func:`pointer` function does more than simply create
pointer instances, it has to create pointer *types* first. This is done with the
:func:`POINTER` function, which ... | trusted_official_docs | CPython Docs | if you receive a pointer from a C function, and you *know* that the pointer actually points to an array instead of a single item.
Behind the scenes, the :func:`pointer` function does more than simply create
pointer instances, it has to create pointer *types* first. This is done with the
:func:`POINTER` function, which ... | if you receive a pointer from a C function, and you *know* that the pointer actually points to an array instead of a single item.
Behind the scenes, the :func:`pointer` function does more than simply create
pointer instances, it has to create pointer *types* first. This is done with the
:func:`POINTER` function, which ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ecb6e5a5-4680-4cbc-8264-ee974e911c12 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,239 | supabase-export-v2 | a43c67515f7697c6 | Since these types are mutable, their value can also be changed afterwards::
>>> i = c_int(42)
>>> print(i)
c_long(42)
>>> print(i.value)
42
>>> i.value = -99
>>> print(i.value)
-99
>>> | trusted_official_docs | CPython Docs | Since these types are mutable, their value can also be changed afterwards::
>>> i = c_int(42)
>>> print(i)
c_long(42)
>>> print(i.value)
42
>>> i.value = -99
>>> print(i.value)
-99
>>> | Since these types are mutable, their value can also be changed afterwards::
>>> i = c_int(42)
>>> print(i)
c_long(42)
>>> print(i.value)
42
>>> i.value = -99
>>> print(i.value)
-99
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ed8ee54e-5b6d-4bcc-a09b-f513bd4216cd | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,225 | supabase-export-v2 | a8fe5ae879c9c57f | *` or :c:expr:`wchar_t *`). Python integers are passed as the platform's default C :c:expr:`int` type, their value is masked to fit into the C type.
Before we move on calling functions with other parameter types, we have to learn
more about :mod:`!ctypes` data types. | trusted_official_docs | CPython Docs | *` or :c:expr:`wchar_t *`). Python integers are passed as the platform's default C :c:expr:`int` type, their value is masked to fit into the C type.
Before we move on calling functions with other parameter types, we have to learn
more about :mod:`!ctypes` data types. | *` or :c:expr:`wchar_t *`). Python integers are passed as the platform's default C :c:expr:`int` type, their value is masked to fit into the C type.
Before we move on calling functions with other parameter types, we have to learn
more about :mod:`!ctypes` data types. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
edb14256-e882-4785-849b-289599570bea | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,550 | supabase-export-v2 | 54f7a26ea4037b23 | entry of this list represents the current process itself, which may be an empty string. For example, on glibc-based Linux, the return may look like::
>>> from ctypes.util import dllist
>>> dllist()
['', 'linux-vdso.so.1', '/lib/x86_64-linux-gnu/libm.so.6', '/lib/x86_64-linux-gnu/libc.so.6', ... ] | trusted_official_docs | CPython Docs | entry of this list represents the current process itself, which may be an empty string. For example, on glibc-based Linux, the return may look like::
>>> from ctypes.util import dllist
>>> dllist()
['', 'linux-vdso.so.1', '/lib/x86_64-linux-gnu/libm.so.6', '/lib/x86_64-linux-gnu/libc.so.6', ... ] | entry of this list represents the current process itself, which may be an empty string. For example, on glibc-based Linux, the return may look like::
>>> from ctypes.util import dllist
>>> dllist()
['', 'linux-vdso.so.1', '/lib/x86_64-linux-gnu/libm.so.6', '/lib/x86_64-linux-gnu/libc.so.6', ... ] | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
eef500e0-a8ae-4d75-9aa6-a89ff7534bf7 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,214 | supabase-export-v2 | c12ba71e8ed9d495 | You can call these functions like any other Python callable. This example uses the ``rand()`` function, which takes no arguments and returns a pseudo-random integer::
>>> print(libc.rand()) # doctest: +SKIP
1804289383 | trusted_official_docs | CPython Docs | You can call these functions like any other Python callable. This example uses the ``rand()`` function, which takes no arguments and returns a pseudo-random integer::
>>> print(libc.rand()) # doctest: +SKIP
1804289383 | You can call these functions like any other Python callable. This example uses the ``rand()`` function, which takes no arguments and returns a pseudo-random integer::
>>> print(libc.rand()) # doctest: +SKIP
1804289383 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ef641b85-cf30-44f7-85be-023f74adfddc | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,752 | supabase-export-v2 | 5187d64e3ecec6d7 | subclass of :class:`_CData`, so it inherits their methods and attributes. ctypes data types that are not and do not contain pointers can now be pickled.
Instances have a single attribute: | trusted_official_docs | CPython Docs | subclass of :class:`_CData`, so it inherits their methods and attributes. ctypes data types that are not and do not contain pointers can now be pickled.
Instances have a single attribute: | subclass of :class:`_CData`, so it inherits their methods and attributes. ctypes data types that are not and do not contain pointers can now be pickled.
Instances have a single attribute: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f0bd40ad-4a73-4092-94ef-529e13240307 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,574 | supabase-export-v2 | 46278fe4f0f29027 | *arguments* is a tuple containing the parameters originally passed to the function call, this allows specializing the behavior on the arguments used.
The object that this function returns will be returned from the
foreign function call, but it can also check the result value
and raise an exception if the foreign func... | trusted_official_docs | CPython Docs | *arguments* is a tuple containing the parameters originally passed to the function call, this allows specializing the behavior on the arguments used.
The object that this function returns will be returned from the
foreign function call, but it can also check the result value
and raise an exception if the foreign func... | *arguments* is a tuple containing the parameters originally passed to the function call, this allows specializing the behavior on the arguments used.
The object that this function returns will be returned from the
foreign function call, but it can also check the result value
and raise an exception if the foreign func... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f0c26453-5009-4845-a125-e961995e600f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,288 | supabase-export-v2 | 0901962a28ca55bc | call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in ValidHandle OSError: [Errno 126] The specified module could not be found. >>>
``WinError`` is a function which will call Windows ``FormatMessage()`` api to
get the string representation of an error code, and *returns* an exception. ``WinError`` ... | trusted_official_docs | CPython Docs | call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in ValidHandle OSError: [Errno 126] The specified module could not be found. >>>
``WinError`` is a function which will call Windows ``FormatMessage()`` api to
get the string representation of an error code, and *returns* an exception. ``WinError`` ... | call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in ValidHandle OSError: [Errno 126] The specified module could not be found. >>>
``WinError`` is a function which will call Windows ``FormatMessage()`` api to
get the string representation of an error code, and *returns* an exception. ``WinError`` ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f231a0fb-808a-479b-93f9-579ddce1d019 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,274 | supabase-export-v2 | e1085ba9d1512ce7 | from ctypes import CDLL, c_char, c_char_p from ctypes.util import find_library libc = CDLL(find_library('c')) strchr = libc.strchr
By default functions are assumed to return the C :c:expr:`int` type. Other
return types can be specified by setting the :attr:`~_CFuncPtr.restype` attribute of the
function object. | trusted_official_docs | CPython Docs | from ctypes import CDLL, c_char, c_char_p from ctypes.util import find_library libc = CDLL(find_library('c')) strchr = libc.strchr
By default functions are assumed to return the C :c:expr:`int` type. Other
return types can be specified by setting the :attr:`~_CFuncPtr.restype` attribute of the
function object. | from ctypes import CDLL, c_char, c_char_p from ctypes.util import find_library libc = CDLL(find_library('c')) strchr = libc.strchr
By default functions are assumed to return the C :c:expr:`int` type. Other
return types can be specified by setting the :attr:`~_CFuncPtr.restype` attribute of the
function object. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f303f6ad-d01e-4d8b-acc2-1cd39a5d51d9 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,237 | supabase-export-v2 | 1e35d050c374812c | constructors for numeric types will convert input using :py:meth:`~object.__bool__`, :py:meth:`~object.__index__` (for ``int``), :py:meth:`~object.__float__` or :py:meth:`~object.__complex__`. This means :py:class:`~ctypes.c_bool` accepts any object with a truth value::
>>> empty_list = []
>>> c_bool(empty_list)
c_bo... | trusted_official_docs | CPython Docs | constructors for numeric types will convert input using :py:meth:`~object.__bool__`, :py:meth:`~object.__index__` (for ``int``), :py:meth:`~object.__float__` or :py:meth:`~object.__complex__`. This means :py:class:`~ctypes.c_bool` accepts any object with a truth value::
>>> empty_list = []
>>> c_bool(empty_list)
c_bo... | constructors for numeric types will convert input using :py:meth:`~object.__bool__`, :py:meth:`~object.__index__` (for ``int``), :py:meth:`~object.__float__` or :py:meth:`~object.__complex__`. This means :py:class:`~ctypes.c_bool` accepts any object with a truth value::
>>> empty_list = []
>>> c_bool(empty_list)
c_bo... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f44a9730-89dc-4386-bce1-208da6e91ec9 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,431 | supabase-export-v2 | 93a81d5e1bdd8228 | expected the last statement to print ``3 4 1 2``. What happened? Here are the steps of the ``rc.a, rc.b = rc.b, rc.a`` line above::
>>> temp0, temp1 = rc.b, rc.a
>>> rc.a = temp0
>>> rc.b = temp1
>>> | trusted_official_docs | CPython Docs | expected the last statement to print ``3 4 1 2``. What happened? Here are the steps of the ``rc.a, rc.b = rc.b, rc.a`` line above::
>>> temp0, temp1 = rc.b, rc.a
>>> rc.a = temp0
>>> rc.b = temp1
>>> | expected the last statement to print ``3 4 1 2``. What happened? Here are the steps of the ``rc.a, rc.b = rc.b, rc.a`` line above::
>>> temp0, temp1 = rc.b, rc.a
>>> rc.a = temp0
>>> rc.b = temp1
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f60166b0-e43d-4382-b9f8-135d0e875022 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,670 | supabase-export-v2 | 3fa60524c5ca7580 | .. function:: FormatError([code])
Returns a textual description of the error code *code*. If no error code is
specified, the last error code is used by calling the Windows API function
:func:`GetLastError`. | trusted_official_docs | CPython Docs | .. function:: FormatError([code])
Returns a textual description of the error code *code*. If no error code is
specified, the last error code is used by calling the Windows API function
:func:`GetLastError`. | .. function:: FormatError([code])
Returns a textual description of the error code *code*. If no error code is
specified, the last error code is used by calling the Windows API function
:func:`GetLastError`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f6a41622-0ca0-40ef-bb78-3f1ea85fe476 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,206 | supabase-export-v2 | c8b89357ba9f7ed0 | /* ANSI version */ HMODULE GetModuleHandleA(LPCSTR lpModuleName); /* UNICODE version */ HMODULE GetModuleHandleW(LPCWSTR lpModuleName);
*windll* does not try to select one of them by magic, you must access the
version you need by specifying ``GetModuleHandleA`` or ``GetModuleHandleW``
explicitly, and then call it with ... | trusted_official_docs | CPython Docs | /* ANSI version */ HMODULE GetModuleHandleA(LPCSTR lpModuleName); /* UNICODE version */ HMODULE GetModuleHandleW(LPCWSTR lpModuleName);
*windll* does not try to select one of them by magic, you must access the
version you need by specifying ``GetModuleHandleA`` or ``GetModuleHandleW``
explicitly, and then call it with ... | /* ANSI version */ HMODULE GetModuleHandleA(LPCSTR lpModuleName); /* UNICODE version */ HMODULE GetModuleHandleW(LPCWSTR lpModuleName);
*windll* does not try to select one of them by magic, you must access the
version you need by specifying ``GetModuleHandleA`` or ``GetModuleHandleW``
explicitly, and then call it with ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f738f41a-f8e0-4c83-9476-1d205b872f4a | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,582 | supabase-export-v2 | c88532b9201c384e | of the function, and can be used as decorator factories, and as such, be applied to functions through the ``@wrapper`` syntax. See :ref:`ctypes-callback-functions` for examples.
.. function:: CFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False) | trusted_official_docs | CPython Docs | of the function, and can be used as decorator factories, and as such, be applied to functions through the ``@wrapper`` syntax. See :ref:`ctypes-callback-functions` for examples.
.. function:: CFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False) | of the function, and can be used as decorator factories, and as such, be applied to functions through the ``@wrapper`` syntax. See :ref:`ctypes-callback-functions` for examples.
.. function:: CFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f740705a-8963-4843-b9ba-37174986ea4c | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,338 | supabase-export-v2 | 83aea7827da75ce2 | >>> pi.contents is i False >>> pi.contents is pi.contents False >>>
Assigning another :class:`c_int` instance to the pointer's contents attribute
would cause the pointer to point to the memory location where this is stored:: | trusted_official_docs | CPython Docs | >>> pi.contents is i False >>> pi.contents is pi.contents False >>>
Assigning another :class:`c_int` instance to the pointer's contents attribute
would cause the pointer to point to the memory location where this is stored:: | >>> pi.contents is i False >>> pi.contents is pi.contents False >>>
Assigning another :class:`c_int` instance to the pointer's contents attribute
would cause the pointer to point to the memory location where this is stored:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f88c72a5-878b-40bc-8636-ffbddec15593 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,208 | supabase-export-v2 | ade7ff757254babd | Sometimes, dlls export functions with names which aren't valid Python identifiers, like ``"??2@YAPAXI@Z"``. In this case you have to use :func:`getattr` to retrieve the function::
>>> getattr(cdll.msvcrt, "??2@YAPAXI@Z") # doctest: +WINDOWS
<_FuncPtr object at 0x...>
>>> | trusted_official_docs | CPython Docs | Sometimes, dlls export functions with names which aren't valid Python identifiers, like ``"??2@YAPAXI@Z"``. In this case you have to use :func:`getattr` to retrieve the function::
>>> getattr(cdll.msvcrt, "??2@YAPAXI@Z") # doctest: +WINDOWS
<_FuncPtr object at 0x...>
>>> | Sometimes, dlls export functions with names which aren't valid Python identifiers, like ``"??2@YAPAXI@Z"``. In this case you have to use :func:`getattr` to retrieve the function::
>>> getattr(cdll.msvcrt, "??2@YAPAXI@Z") # doctest: +WINDOWS
<_FuncPtr object at 0x...>
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f97fcc92-4b72-4663-b1b2-630fce434b80 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,337 | supabase-export-v2 | 997993b30989a208 | Note that :mod:`!ctypes` does not have OOR (original object return), it constructs a new, equivalent object each time you retrieve an attribute::
>>> pi.contents is i
False
>>> pi.contents is pi.contents
False
>>> | trusted_official_docs | CPython Docs | Note that :mod:`!ctypes` does not have OOR (original object return), it constructs a new, equivalent object each time you retrieve an attribute::
>>> pi.contents is i
False
>>> pi.contents is pi.contents
False
>>> | Note that :mod:`!ctypes` does not have OOR (original object return), it constructs a new, equivalent object each time you retrieve an attribute::
>>> pi.contents is i
False
>>> pi.contents is pi.contents
False
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f983db74-c5a3-4413-8f56-048b14f209e2 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,860 | supabase-export-v2 | ec6e64149183a8e0 | .. attribute:: _fields_
A sequence defining the structure fields. The items must be 2-tuples or
3-tuples. The first item is the name of the field, the second item
specifies the type of the field; it can be any ctypes data type. | trusted_official_docs | CPython Docs | .. attribute:: _fields_
A sequence defining the structure fields. The items must be 2-tuples or
3-tuples. The first item is the name of the field, the second item
specifies the type of the field; it can be any ctypes data type. | .. attribute:: _fields_
A sequence defining the structure fields. The items must be 2-tuples or
3-tuples. The first item is the name of the field, the second item
specifies the type of the field; it can be any ctypes data type. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fab901e3-a81f-4f88-8b3e-7d0a5d539d6a | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,572 | supabase-export-v2 | 705a913f56c80d50 | *result* is what the foreign function returns, as specified by the :attr:`!restype` attribute.
*func* is the foreign function object itself, this allows reusing the
same callable object to check or post process the results of several
functions. | trusted_official_docs | CPython Docs | *result* is what the foreign function returns, as specified by the :attr:`!restype` attribute.
*func* is the foreign function object itself, this allows reusing the
same callable object to check or post process the results of several
functions. | *result* is what the foreign function returns, as specified by the :attr:`!restype` attribute.
*func* is the foreign function object itself, this allows reusing the
same callable object to check or post process the results of several
functions. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fae2f7e9-dc83-4d71-8b35-e59f0a6a2564 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,863 | supabase-export-v2 | 376c068670bf74c0 | Field names must be unique within one structure or union. This is not checked, only one field can be accessed when names are repeated.
It is possible to define the :attr:`_fields_` class variable *after* the
class statement that defines the Structure subclass, this allows creating
data types that directly or indirect... | trusted_official_docs | CPython Docs | Field names must be unique within one structure or union. This is not checked, only one field can be accessed when names are repeated.
It is possible to define the :attr:`_fields_` class variable *after* the
class statement that defines the Structure subclass, this allows creating
data types that directly or indirect... | Field names must be unique within one structure or union. This is not checked, only one field can be accessed when names are repeated.
It is possible to define the :attr:`_fields_` class variable *after* the
class statement that defines the Structure subclass, this allows creating
data types that directly or indirect... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fb4c014a-72fb-448a-8195-0bed6e93c2ba | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,666 | supabase-export-v2 | c142b3b77dd0a7c6 | .. function:: dllist() :module: ctypes.util
Try to provide a list of paths of the shared libraries loaded into the current
process. These paths are not normalized or processed in any way. The function
can raise :exc:`OSError` if the underlying platform APIs fail. The exact functionality is system dependent. | trusted_official_docs | CPython Docs | .. function:: dllist() :module: ctypes.util
Try to provide a list of paths of the shared libraries loaded into the current
process. These paths are not normalized or processed in any way. The function
can raise :exc:`OSError` if the underlying platform APIs fail. The exact functionality is system dependent. | .. function:: dllist() :module: ctypes.util
Try to provide a list of paths of the shared libraries loaded into the current
process. These paths are not normalized or processed in any way. The function
can raise :exc:`OSError` if the underlying platform APIs fail. The exact functionality is system dependent. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fb5a29eb-1560-435f-b167-a767a4edf69f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,786 | supabase-export-v2 | f9b5dfbf3326e55e | .. class:: c_int
Represents the C :c:expr:`signed int` datatype. The constructor accepts an
optional integer initializer; no overflow checking is done. On platforms
where ``sizeof(int) == sizeof(long)`` it is an alias to :class:`c_long`. | trusted_official_docs | CPython Docs | .. class:: c_int
Represents the C :c:expr:`signed int` datatype. The constructor accepts an
optional integer initializer; no overflow checking is done. On platforms
where ``sizeof(int) == sizeof(long)`` it is an alias to :class:`c_long`. | .. class:: c_int
Represents the C :c:expr:`signed int` datatype. The constructor accepts an
optional integer initializer; no overflow checking is done. On platforms
where ``sizeof(int) == sizeof(long)`` it is an alias to :class:`c_long`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fc3c8175-22c8-462a-80d1-8e242301aa77 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,254 | supabase-export-v2 | f037321390bbd76d | of parameters. On some platforms, and in particular ARM64 for Apple Platforms, the calling convention for variadic functions is different than that for regular functions.
On those platforms it is required to specify the :attr:`~_CFuncPtr.argtypes`
attribute for the regular, non-variadic, function arguments: | trusted_official_docs | CPython Docs | of parameters. On some platforms, and in particular ARM64 for Apple Platforms, the calling convention for variadic functions is different than that for regular functions.
On those platforms it is required to specify the :attr:`~_CFuncPtr.argtypes`
attribute for the regular, non-variadic, function arguments: | of parameters. On some platforms, and in particular ARM64 for Apple Platforms, the calling convention for variadic functions is different than that for regular functions.
On those platforms it is required to specify the :attr:`~_CFuncPtr.argtypes`
attribute for the regular, non-variadic, function arguments: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fd85ee4c-f8a9-44c0-bad5-769b350a43f7 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,302 | supabase-export-v2 | c2cc3619a15ddc9b | You can, however, build much more complicated structures. A structure can itself contain other structures by using a structure as a field type.
Here is a RECT structure which contains two POINTs named *upperleft* and
*lowerright*:: | trusted_official_docs | CPython Docs | You can, however, build much more complicated structures. A structure can itself contain other structures by using a structure as a field type.
Here is a RECT structure which contains two POINTs named *upperleft* and
*lowerright*:: | You can, however, build much more complicated structures. A structure can itself contain other structures by using a structure as a field type.
Here is a RECT structure which contains two POINTs named *upperleft* and
*lowerright*:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ff96586b-4949-4d81-9109-d131463569f2 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,643 | supabase-export-v2 | 58c0335ac69a8253 | .. function:: cast(obj, type)
This function is similar to the cast operator in C. It returns a new instance
of *type* which points to the same memory block as *obj*. *type* must be a
pointer type, and *obj* must be an object that can be interpreted as a
pointer. | trusted_official_docs | CPython Docs | .. function:: cast(obj, type)
This function is similar to the cast operator in C. It returns a new instance
of *type* which points to the same memory block as *obj*. *type* must be a
pointer type, and *obj* must be an object that can be interpreted as a
pointer. | .. function:: cast(obj, type)
This function is similar to the cast operator in C. It returns a new instance
of *type* which points to the same memory block as *obj*. *type* must be a
pointer type, and *obj* must be an object that can be interpreted as a
pointer. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fffcd27f-32ab-47e9-b3f1-c9c768ad918c | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,300 | supabase-export-v2 | e191bf2d1de924ae | simple example of a POINT structure, which contains two integers named *x* and *y*, and also shows how to initialize a structure in the constructor::
>>> from ctypes import *
>>> class POINT(Structure):
... _fields_ = [("x", c_int),
... ("y", c_int)]
... >>> point = POINT(10, 20)
>>> print(point.x, point.y)
10 20... | trusted_official_docs | CPython Docs | simple example of a POINT structure, which contains two integers named *x* and *y*, and also shows how to initialize a structure in the constructor::
>>> from ctypes import *
>>> class POINT(Structure):
... _fields_ = [("x", c_int),
... ("y", c_int)]
... >>> point = POINT(10, 20)
>>> print(point.x, point.y)
10 20... | simple example of a POINT structure, which contains two integers named *x* and *y*, and also shows how to initialize a structure in the constructor::
>>> from ctypes import *
>>> class POINT(Structure):
... _fields_ = [("x", c_int),
... ("y", c_int)]
... >>> point = POINT(10, 20)
>>> print(point.x, point.y)
10 20... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
085e2578-0060-4bc4-a3bf-3b8643a43619 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,981 | supabase-export-v2 | 87c80230d60ace70 | map's underlying file. This means that the :meth:`~mmap.mmap.size` and :meth:`~mmap.mmap.resize` methods will fail. This mode is useful to limit the number of open file descriptors.
To ensure validity of the created memory mapping the file specified
by the descriptor *fileno* is internally automatically synchronized
... | trusted_official_docs | CPython Docs | map's underlying file. This means that the :meth:`~mmap.mmap.size` and :meth:`~mmap.mmap.resize` methods will fail. This mode is useful to limit the number of open file descriptors.
To ensure validity of the created memory mapping the file specified
by the descriptor *fileno* is internally automatically synchronized
... | map's underlying file. This means that the :meth:`~mmap.mmap.size` and :meth:`~mmap.mmap.resize` methods will fail. This mode is useful to limit the number of open file descriptors.
To ensure validity of the created memory mapping the file specified
by the descriptor *fileno* is internally automatically synchronized
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0cab9d89-dcd8-45e5-96c4-77679b8f7639 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,965 | supabase-export-v2 | b3cdbdca9bc6406e | :const:`ACCESS_WRITE` memory map affects both memory and the underlying file. Assignment to an :const:`ACCESS_COPY` memory map affects memory but does not update the underlying file.
.. versionchanged:: 3.7
Added :const:`ACCESS_DEFAULT` constant. | trusted_official_docs | CPython Docs | :const:`ACCESS_WRITE` memory map affects both memory and the underlying file. Assignment to an :const:`ACCESS_COPY` memory map affects memory but does not update the underlying file.
.. versionchanged:: 3.7
Added :const:`ACCESS_DEFAULT` constant. | :const:`ACCESS_WRITE` memory map affects both memory and the underlying file. Assignment to an :const:`ACCESS_COPY` memory map affects memory but does not update the underlying file.
.. versionchanged:: 3.7
Added :const:`ACCESS_DEFAULT` constant. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
116dd1f4-b780-4303-adb4-49b1f4f1d63a | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,975 | supabase-export-v2 | cb3ade53f0eb7fa9 | .. class:: mmap(fileno, length, flags=MAP_SHARED, prot=PROT_WRITE|PROT_READ, \ access=ACCESS_DEFAULT, offset=0, *, trackfd=True) :noindex:
**(Unix version)** Maps *length* bytes from the file specified by the file
descriptor *fileno*, and returns a mmap object. If *length* is ``0``, the
maximum length of the map will... | trusted_official_docs | CPython Docs | .. class:: mmap(fileno, length, flags=MAP_SHARED, prot=PROT_WRITE|PROT_READ, \ access=ACCESS_DEFAULT, offset=0, *, trackfd=True) :noindex:
**(Unix version)** Maps *length* bytes from the file specified by the file
descriptor *fileno*, and returns a mmap object. If *length* is ``0``, the
maximum length of the map will... | .. class:: mmap(fileno, length, flags=MAP_SHARED, prot=PROT_WRITE|PROT_READ, \ access=ACCESS_DEFAULT, offset=0, *, trackfd=True) :noindex:
**(Unix version)** Maps *length* bytes from the file specified by the file
descriptor *fileno*, and returns a mmap object. If *length* is ``0``, the
maximum length of the map will... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
22aa6eeb-0d4c-45e4-93e0-47f88b802c15 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,005 | supabase-export-v2 | ba76e088b4257dea | .. method:: find(sub[, start[, end]])
Returns the lowest index in the object where the subsequence *sub* is
found, such that *sub* is contained in the range [*start*, *end*]. Optional arguments *start* and *end* are interpreted as in slice notation. Returns ``-1`` on failure. | trusted_official_docs | CPython Docs | .. method:: find(sub[, start[, end]])
Returns the lowest index in the object where the subsequence *sub* is
found, such that *sub* is contained in the range [*start*, *end*]. Optional arguments *start* and *end* are interpreted as in slice notation. Returns ``-1`` on failure. | .. method:: find(sub[, start[, end]])
Returns the lowest index in the object where the subsequence *sub* is
found, such that *sub* is contained in the range [*start*, *end*]. Optional arguments *start* and *end* are interpreted as in slice notation. Returns ``-1`` on failure. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
22ae73e0-ad26-4c77-825e-6801d57d4a0b | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,970 | supabase-export-v2 | 2d531c263176cd36 | the mapping is created without a name. Avoiding the use of the *tagname* parameter will assist in keeping your code portable between Unix and Windows.
*offset* may be specified as a non-negative integer offset. mmap references
will be relative to the offset from the beginning of the file. *offset*
defaults to 0. *off... | trusted_official_docs | CPython Docs | the mapping is created without a name. Avoiding the use of the *tagname* parameter will assist in keeping your code portable between Unix and Windows.
*offset* may be specified as a non-negative integer offset. mmap references
will be relative to the offset from the beginning of the file. *offset*
defaults to 0. *off... | the mapping is created without a name. Avoiding the use of the *tagname* parameter will assist in keeping your code portable between Unix and Windows.
*offset* may be specified as a non-negative integer offset. mmap references
will be relative to the offset from the beginning of the file. *offset*
defaults to 0. *off... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
232de343-d22a-4630-8f32-c1eb61eee489 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,073 | supabase-export-v2 | b6e18ccda8bc15a3 | These flags control the synchronization behavior for :meth:`mmap.flush`:
* :data:`MS_SYNC` - Synchronous flush: writes are scheduled and the call
blocks until they are physically written to storage. * :data:`MS_ASYNC` - Asynchronous flush: writes are scheduled but the call
returns immediately without waiting for comp... | trusted_official_docs | CPython Docs | These flags control the synchronization behavior for :meth:`mmap.flush`:
* :data:`MS_SYNC` - Synchronous flush: writes are scheduled and the call
blocks until they are physically written to storage. * :data:`MS_ASYNC` - Asynchronous flush: writes are scheduled but the call
returns immediately without waiting for comp... | These flags control the synchronization behavior for :meth:`mmap.flush`:
* :data:`MS_SYNC` - Synchronous flush: writes are scheduled and the call
blocks until they are physically written to storage. * :data:`MS_ASYNC` - Asynchronous flush: writes are scheduled but the call
returns immediately without waiting for comp... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3138375a-669a-4bc0-8c13-b23e5147d604 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,013 | supabase-export-v2 | ef39aca051f7fa34 | returned on success; zero was returned on error under Windows. A zero value was returned on success; an exception was raised on error under Unix.
.. versionchanged:: 3.15
Allow specifying *offset* without *size*. Previously, both *offset*
and *size* parameters were required together. Now *offset* can be
specified al... | trusted_official_docs | CPython Docs | returned on success; zero was returned on error under Windows. A zero value was returned on success; an exception was raised on error under Unix.
.. versionchanged:: 3.15
Allow specifying *offset* without *size*. Previously, both *offset*
and *size* parameters were required together. Now *offset* can be
specified al... | returned on success; zero was returned on error under Windows. A zero value was returned on success; an exception was raised on error under Unix.
.. versionchanged:: 3.15
Allow specifying *offset* without *size*. Previously, both *offset*
and *size* parameters were required together. Now *offset* can be
specified al... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
39914cf8-58e5-4d00-ae46-df71ab07b185 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,039 | supabase-export-v2 | 787f11eb27eadbe5 | (absolute file positioning); other values are ``os.SEEK_CUR`` or ``1`` (seek relative to the current position) and ``os.SEEK_END`` or ``2`` (seek relative to the file's end).
.. versionchanged:: 3.13
Return the new absolute position instead of ``None``. | trusted_official_docs | CPython Docs | (absolute file positioning); other values are ``os.SEEK_CUR`` or ``1`` (seek relative to the current position) and ``os.SEEK_END`` or ``2`` (seek relative to the file's end).
.. versionchanged:: 3.13
Return the new absolute position instead of ``None``. | (absolute file positioning); other values are ``os.SEEK_CUR`` or ``1`` (seek relative to the current position) and ``os.SEEK_END`` or ``2`` (seek relative to the file's end).
.. versionchanged:: 3.13
Return the new absolute position instead of ``None``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3a4b87bd-6eae-41cf-a949-6a2734aa12d0 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,979 | supabase-export-v2 | b82dfbde4154c12f | It is an error to specify both *flags*, *prot* and *access*. See the description of *access* above for information on how to use this parameter.
*offset* may be specified as a non-negative integer offset. mmap references
will be relative to the offset from the beginning of the file. *offset*
defaults to 0. *offset* m... | trusted_official_docs | CPython Docs | It is an error to specify both *flags*, *prot* and *access*. See the description of *access* above for information on how to use this parameter.
*offset* may be specified as a non-negative integer offset. mmap references
will be relative to the offset from the beginning of the file. *offset*
defaults to 0. *offset* m... | It is an error to specify both *flags*, *prot* and *access*. See the description of *access* above for information on how to use this parameter.
*offset* may be specified as a non-negative integer offset. mmap references
will be relative to the offset from the beginning of the file. *offset*
defaults to 0. *offset* m... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3ab30ba8-272d-4e78-aa66-a73605b1837f | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,961 | supabase-export-v2 | 7584fd5d8c7480e5 | .. include:: ../includes/wasm-notavail.rst
Memory-mapped file objects behave like both :class:`bytearray` and like
:term:`file objects <file object>`. You can use mmap objects in most places
where :class:`bytearray` are expected; for example, you can use the :mod:`re`
module to search through a memory-mapped file. You ... | trusted_official_docs | CPython Docs | .. include:: ../includes/wasm-notavail.rst
Memory-mapped file objects behave like both :class:`bytearray` and like
:term:`file objects <file object>`. You can use mmap objects in most places
where :class:`bytearray` are expected; for example, you can use the :mod:`re`
module to search through a memory-mapped file. You ... | .. include:: ../includes/wasm-notavail.rst
Memory-mapped file objects behave like both :class:`bytearray` and like
:term:`file objects <file object>`. You can use mmap objects in most places
where :class:`bytearray` are expected; for example, you can use the :mod:`re`
module to search through a memory-mapped file. You ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
49268a86-9936-492c-ba70-1aec42e3a976 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,963 | supabase-export-v2 | e4e766e6c2c22f84 | Otherwise, you can open the file using the :func:`os.open` function, which returns a file descriptor directly (the file still needs to be closed when done).
.. note::
If you want to create a memory-mapping for a writable, buffered file, you
should :func:`~io.IOBase.flush` the file first. This is necessary to ensure
... | trusted_official_docs | CPython Docs | Otherwise, you can open the file using the :func:`os.open` function, which returns a file descriptor directly (the file still needs to be closed when done).
.. note::
If you want to create a memory-mapping for a writable, buffered file, you
should :func:`~io.IOBase.flush` the file first. This is necessary to ensure
... | Otherwise, you can open the file using the :func:`os.open` function, which returns a file descriptor directly (the file still needs to be closed when done).
.. note::
If you want to create a memory-mapping for a writable, buffered file, you
should :func:`~io.IOBase.flush` the file first. This is necessary to ensure
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4e2793bb-e108-49f8-bab2-4b236c58d7c5 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,982 | supabase-export-v2 | 86589b47769d9235 | ensure validity of the created memory mapping the file specified by the descriptor *fileno* is internally automatically synchronized with the physical backing store on macOS.
.. versionchanged:: 3.13
The *trackfd* parameter was added. | trusted_official_docs | CPython Docs | ensure validity of the created memory mapping the file specified by the descriptor *fileno* is internally automatically synchronized with the physical backing store on macOS.
.. versionchanged:: 3.13
The *trackfd* parameter was added. | ensure validity of the created memory mapping the file specified by the descriptor *fileno* is internally automatically synchronized with the physical backing store on macOS.
.. versionchanged:: 3.13
The *trackfd* parameter was added. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
50acb1ca-917f-4539-9824-1507f8c66c0f | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,035 | supabase-export-v2 | ba06c6fbfd22331e | .. method:: rfind(sub[, start[, end]])
Returns the highest index in the object where the subsequence *sub* is
found, such that *sub* is contained in the range [*start*, *end*]. Optional arguments *start* and *end* are interpreted as in slice notation. Returns ``-1`` on failure. | trusted_official_docs | CPython Docs | .. method:: rfind(sub[, start[, end]])
Returns the highest index in the object where the subsequence *sub* is
found, such that *sub* is contained in the range [*start*, *end*]. Optional arguments *start* and *end* are interpreted as in slice notation. Returns ``-1`` on failure. | .. method:: rfind(sub[, start[, end]])
Returns the highest index in the object where the subsequence *sub* is
found, such that *sub* is contained in the range [*start*, *end*]. Optional arguments *start* and *end* are interpreted as in slice notation. Returns ``-1`` on failure. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
57566f07-1e80-45cd-9043-e99ca01ea8e9 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,045 | supabase-export-v2 | 4bc265295883c0cb | passed to Python or if Python is built in :ref:`debug mode <debug-build>`. The length of *name* must not exceed 67 bytes including the ``'\0'`` terminator.
.. availability:: Linux >= 5.17 (kernel built with ``CONFIG_ANON_VMA_NAME`` option) | trusted_official_docs | CPython Docs | passed to Python or if Python is built in :ref:`debug mode <debug-build>`. The length of *name* must not exceed 67 bytes including the ``'\0'`` terminator.
.. availability:: Linux >= 5.17 (kernel built with ``CONFIG_ANON_VMA_NAME`` option) | passed to Python or if Python is built in :ref:`debug mode <debug-build>`. The length of *name* must not exceed 67 bytes including the ``'\0'`` terminator.
.. availability:: Linux >= 5.17 (kernel built with ``CONFIG_ANON_VMA_NAME`` option) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
57977948-72db-41be-a81b-1b4a64c5c73e | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,020 | supabase-export-v2 | ec07c5254d219318 | .. method:: move(dest, src, count)
Copy the *count* bytes starting at offset *src* to the destination index
*dest*. If the mmap was created with :const:`ACCESS_READ`, then calls to
move will raise a :exc:`TypeError` exception. | trusted_official_docs | CPython Docs | .. method:: move(dest, src, count)
Copy the *count* bytes starting at offset *src* to the destination index
*dest*. If the mmap was created with :const:`ACCESS_READ`, then calls to
move will raise a :exc:`TypeError` exception. | .. method:: move(dest, src, count)
Copy the *count* bytes starting at offset *src* to the destination index
*dest*. If the mmap was created with :const:`ACCESS_READ`, then calls to
move will raise a :exc:`TypeError` exception. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5b649420-0b32-44d8-baa4-e09e7126c18c | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,972 | supabase-export-v2 | 50d89fb2c955841f | fail. This mode is useful to limit the number of open file handles. The original file can be renamed (but not deleted) after closing *fileno*.
.. versionchanged:: 3.15
The *trackfd* parameter was added. | trusted_official_docs | CPython Docs | fail. This mode is useful to limit the number of open file handles. The original file can be renamed (but not deleted) after closing *fileno*.
.. versionchanged:: 3.15
The *trackfd* parameter was added. | fail. This mode is useful to limit the number of open file handles. The original file can be renamed (but not deleted) after closing *fileno*.
.. versionchanged:: 3.15
The *trackfd* parameter was added. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5e860c07-8fb1-4e86-92b6-74baca056204 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,006 | supabase-export-v2 | 287f1617fab5d744 | such that *sub* is contained in the range [*start*, *end*]. Optional arguments *start* and *end* are interpreted as in slice notation. Returns ``-1`` on failure.
.. versionchanged:: 3.5
Writable :term:`bytes-like object` is now accepted. | trusted_official_docs | CPython Docs | such that *sub* is contained in the range [*start*, *end*]. Optional arguments *start* and *end* are interpreted as in slice notation. Returns ``-1`` on failure.
.. versionchanged:: 3.5
Writable :term:`bytes-like object` is now accepted. | such that *sub* is contained in the range [*start*, *end*]. Optional arguments *start* and *end* are interpreted as in slice notation. Returns ``-1`` on failure.
.. versionchanged:: 3.5
Writable :term:`bytes-like object` is now accepted. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
65358125-21b2-4b87-889c-b5dfff6782e9 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,980 | supabase-export-v2 | a4c597a4c00792e2 | from the beginning of the file. *offset* defaults to 0. *offset* must be a multiple of :const:`ALLOCATIONGRANULARITY` which is equal to :const:`PAGESIZE` on Unix systems.
If *trackfd* is ``False``, the file descriptor specified by *fileno* will
not be duplicated, and the resulting :class:`!mmap` object will not
be as... | trusted_official_docs | CPython Docs | from the beginning of the file. *offset* defaults to 0. *offset* must be a multiple of :const:`ALLOCATIONGRANULARITY` which is equal to :const:`PAGESIZE` on Unix systems.
If *trackfd* is ``False``, the file descriptor specified by *fileno* will
not be duplicated, and the resulting :class:`!mmap` object will not
be as... | from the beginning of the file. *offset* defaults to 0. *offset* must be a multiple of :const:`ALLOCATIONGRANULARITY` which is equal to :const:`PAGESIZE` on Unix systems.
If *trackfd* is ``False``, the file descriptor specified by *fileno* will
not be duplicated, and the resulting :class:`!mmap` object will not
be as... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
668d28ea-cb79-41ca-89e8-335cc074e262 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,962 | supabase-export-v2 | a2110ffcfd126fa2 | slice: ``obj[i1:i2] = b'...'``. You can also read and write data starting at the current file position, and :meth:`seek` through the file to different positions.
A memory-mapped file is created by the :class:`~mmap.mmap` constructor, which is
different on Unix and on Windows. In either case you must provide a file
desc... | trusted_official_docs | CPython Docs | slice: ``obj[i1:i2] = b'...'``. You can also read and write data starting at the current file position, and :meth:`seek` through the file to different positions.
A memory-mapped file is created by the :class:`~mmap.mmap` constructor, which is
different on Unix and on Windows. In either case you must provide a file
desc... | slice: ``obj[i1:i2] = b'...'``. You can also read and write data starting at the current file position, and :meth:`seek` through the file to different positions.
A memory-mapped file is created by the :class:`~mmap.mmap` constructor, which is
different on Unix and on Windows. In either case you must provide a file
desc... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6c734a4a-36e5-483a-b79d-9f523002a1b7 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,971 | supabase-export-v2 | b0262558afafb254 | references will be relative to the offset from the beginning of the file. *offset* defaults to 0. *offset* must be a multiple of the :const:`ALLOCATIONGRANULARITY`.
If *trackfd* is ``False``, the file handle corresponding to *fileno* will
not be duplicated, and the resulting :class:`!mmap` object will not
be associat... | trusted_official_docs | CPython Docs | references will be relative to the offset from the beginning of the file. *offset* defaults to 0. *offset* must be a multiple of the :const:`ALLOCATIONGRANULARITY`.
If *trackfd* is ``False``, the file handle corresponding to *fileno* will
not be duplicated, and the resulting :class:`!mmap` object will not
be associat... | references will be relative to the offset from the beginning of the file. *offset* defaults to 0. *offset* must be a multiple of the :const:`ALLOCATIONGRANULARITY`.
If *trackfd* is ``False``, the file handle corresponding to *fileno* will
not be duplicated, and the resulting :class:`!mmap` object will not
be associat... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7248f819-bcee-46e5-9132-3a0ccd6b1ba4 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,044 | supabase-export-v2 | 6b3a410013a9ea78 | .. method:: set_name(name, /)
Annotate the memory mapping with the given *name* for easier identification
in ``/proc/<pid>/maps`` if the kernel supports the feature and :option:`-X dev <-X>` is passed
to Python or if Python is built in :ref:`debug mode <debug-build>`. The length of *name* must not exceed 67 bytes inc... | trusted_official_docs | CPython Docs | .. method:: set_name(name, /)
Annotate the memory mapping with the given *name* for easier identification
in ``/proc/<pid>/maps`` if the kernel supports the feature and :option:`-X dev <-X>` is passed
to Python or if Python is built in :ref:`debug mode <debug-build>`. The length of *name* must not exceed 67 bytes inc... | .. method:: set_name(name, /)
Annotate the memory mapping with the given *name* for easier identification
in ``/proc/<pid>/maps`` if the kernel supports the feature and :option:`-X dev <-X>` is passed
to Python or if Python is built in :ref:`debug mode <debug-build>`. The length of *name* must not exceed 67 bytes inc... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
72685727-8a59-4017-986f-cfee1aadb818 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,027 | supabase-export-v2 | 6dd92fe197832892 | .. method:: readline()
Returns a single line, starting at the current file position and up to the
next newline. The file position is updated to point after the bytes that were
returned. | trusted_official_docs | CPython Docs | .. method:: readline()
Returns a single line, starting at the current file position and up to the
next newline. The file position is updated to point after the bytes that were
returned. | .. method:: readline()
Returns a single line, starting at the current file position and up to the
next newline. The file position is updated to point after the bytes that were
returned. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
81ad828a-27ea-495b-b975-7547bbbd0418 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,016 | supabase-export-v2 | cba7f7ddec56c1d6 | .. method:: madvise(option[, start[, length]])
Send advice *option* to the kernel about the memory region beginning at
*start* and extending *length* bytes. *option* must be one of the
:ref:`MADV_* constants <madvise-constants>` available on the system. If
*start* and *length* are omitted, the entire mapping is span... | trusted_official_docs | CPython Docs | .. method:: madvise(option[, start[, length]])
Send advice *option* to the kernel about the memory region beginning at
*start* and extending *length* bytes. *option* must be one of the
:ref:`MADV_* constants <madvise-constants>` available on the system. If
*start* and *length* are omitted, the entire mapping is span... | .. method:: madvise(option[, start[, length]])
Send advice *option* to the kernel about the memory region beginning at
*start* and extending *length* bytes. *option* must be one of the
:ref:`MADV_* constants <madvise-constants>` available on the system. If
*start* and *length* are omitted, the entire mapping is span... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
837e9047-b0f2-4285-9a8b-7866f6c89762 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,009 | supabase-export-v2 | 6db4e98a0521b4ad | bytes will be flushed to disk; otherwise, the whole extent of the mapping is flushed. *offset* must be a multiple of the :const:`PAGESIZE` or :const:`ALLOCATIONGRANULARITY`.
The *flags* parameter specifies the synchronization behavior. *flags* must be one of the :ref:`MS_* constants <ms-constants>` available
on the sy... | trusted_official_docs | CPython Docs | bytes will be flushed to disk; otherwise, the whole extent of the mapping is flushed. *offset* must be a multiple of the :const:`PAGESIZE` or :const:`ALLOCATIONGRANULARITY`.
The *flags* parameter specifies the synchronization behavior. *flags* must be one of the :ref:`MS_* constants <ms-constants>` available
on the sy... | bytes will be flushed to disk; otherwise, the whole extent of the mapping is flushed. *offset* must be a multiple of the :const:`PAGESIZE` or :const:`ALLOCATIONGRANULARITY`.
The *flags* parameter specifies the synchronization behavior. *flags* must be one of the :ref:`MS_* constants <ms-constants>` available
on the sy... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
85321add-864f-4751-8785-0569b00f4694 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,060 | supabase-export-v2 | c56572ce7d183c39 | data:: MADV_NORMAL MADV_RANDOM MADV_SEQUENTIAL MADV_WILLNEED MADV_DONTNEED MADV_REMOVE MADV_DONTFORK MADV_DOFORK MADV_HWPOISON MADV_MERGEABLE MADV_UNMERGEABLE MADV_SOFT_OFFLINE MADV_HUGEPAGE MADV_NOHUGEPAGE MADV_DONTDUMP MADV_DODUMP MADV_FREE MADV_NOSYNC MADV_AUTOSYNC MADV_NOCORE MADV_CORE MADV_PROTECT MADV_FREE_REUSAB... | trusted_official_docs | CPython Docs | data:: MADV_NORMAL MADV_RANDOM MADV_SEQUENTIAL MADV_WILLNEED MADV_DONTNEED MADV_REMOVE MADV_DONTFORK MADV_DOFORK MADV_HWPOISON MADV_MERGEABLE MADV_UNMERGEABLE MADV_SOFT_OFFLINE MADV_HUGEPAGE MADV_NOHUGEPAGE MADV_DONTDUMP MADV_DODUMP MADV_FREE MADV_NOSYNC MADV_AUTOSYNC MADV_NOCORE MADV_CORE MADV_PROTECT MADV_FREE_REUSAB... | data:: MADV_NORMAL MADV_RANDOM MADV_SEQUENTIAL MADV_WILLNEED MADV_DONTNEED MADV_REMOVE MADV_DONTFORK MADV_DOFORK MADV_HWPOISON MADV_MERGEABLE MADV_UNMERGEABLE MADV_SOFT_OFFLINE MADV_HUGEPAGE MADV_NOHUGEPAGE MADV_DONTDUMP MADV_DODUMP MADV_FREE MADV_NOSYNC MADV_AUTOSYNC MADV_NOCORE MADV_CORE MADV_PROTECT MADV_FREE_REUSAB... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8ec97ef2-9a34-41c8-9dd3-a9513efac025 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,023 | supabase-export-v2 | e553c7258c44b752 | bytes from the current file position to the end of the mapping. The file position is updated to point after the bytes that were returned.
.. versionchanged:: 3.3
Argument can be omitted or ``None``. | trusted_official_docs | CPython Docs | bytes from the current file position to the end of the mapping. The file position is updated to point after the bytes that were returned.
.. versionchanged:: 3.3
Argument can be omitted or ``None``. | bytes from the current file position to the end of the mapping. The file position is updated to point after the bytes that were returned.
.. versionchanged:: 3.3
Argument can be omitted or ``None``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
90b67993-6ea8-4deb-8025-9286f4fafc5e | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,017 | supabase-export-v2 | e291b7b8075aac93 | system. If *start* and *length* are omitted, the entire mapping is spanned. On some systems (including Linux), *start* must be a multiple of the :const:`PAGESIZE`.
Availability: Systems with the ``madvise()`` system call. | trusted_official_docs | CPython Docs | system. If *start* and *length* are omitted, the entire mapping is spanned. On some systems (including Linux), *start* must be a multiple of the :const:`PAGESIZE`.
Availability: Systems with the ``madvise()`` system call. | system. If *start* and *length* are omitted, the entire mapping is spanned. On some systems (including Linux), *start* must be a multiple of the :const:`PAGESIZE`.
Availability: Systems with the ``madvise()`` system call. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
93e20555-0c88-44a2-8b82-5959f9d513bc | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,008 | supabase-export-v2 | cec88bbb53e0de71 | .. method:: flush([offset[, size]], *, flags=MS_SYNC)
Flushes changes made to the in-memory copy of a file back to disk. Without
use of this call there is no guarantee that changes are written back before
the object is destroyed. If *offset* and *size* are specified, only
changes to the given range of bytes will be ... | trusted_official_docs | CPython Docs | .. method:: flush([offset[, size]], *, flags=MS_SYNC)
Flushes changes made to the in-memory copy of a file back to disk. Without
use of this call there is no guarantee that changes are written back before
the object is destroyed. If *offset* and *size* are specified, only
changes to the given range of bytes will be ... | .. method:: flush([offset[, size]], *, flags=MS_SYNC)
Flushes changes made to the in-memory copy of a file back to disk. Without
use of this call there is no guarantee that changes are written back before
the object is destroyed. If *offset* and *size* are specified, only
changes to the given range of bytes will be ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
98b602e8-3f00-433f-ab74-db69c4695ea0 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,964 | supabase-export-v2 | 792b18faf4714e3a | buffered file, you should :func:`~io.IOBase.flush` the file first. This is necessary to ensure that local modifications to the buffers are actually available to the mapping.
For both the Unix and Windows versions of the constructor, *access* may be
specified as an optional keyword parameter. *access* accepts one of fou... | trusted_official_docs | CPython Docs | buffered file, you should :func:`~io.IOBase.flush` the file first. This is necessary to ensure that local modifications to the buffers are actually available to the mapping.
For both the Unix and Windows versions of the constructor, *access* may be
specified as an optional keyword parameter. *access* accepts one of fou... | buffered file, you should :func:`~io.IOBase.flush` the file first. This is necessary to ensure that local modifications to the buffers are actually available to the mapping.
For both the Unix and Windows versions of the constructor, *access* may be
specified as an optional keyword parameter. *access* accepts one of fou... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9a1fb384-f0f5-4f45-81a8-4b0bc97c5b4d | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,968 | supabase-export-v2 | e6991e2842120b30 | .. class:: mmap(fileno, length, tagname=None, \ access=ACCESS_DEFAULT, offset=0, *, trackfd=True)
**(Windows version)** Maps *length* bytes from the file specified by the
file descriptor *fileno*, and creates a mmap object. If *length* is larger
than the current size of the file, the file is extended to contain *leng... | trusted_official_docs | CPython Docs | .. class:: mmap(fileno, length, tagname=None, \ access=ACCESS_DEFAULT, offset=0, *, trackfd=True)
**(Windows version)** Maps *length* bytes from the file specified by the
file descriptor *fileno*, and creates a mmap object. If *length* is larger
than the current size of the file, the file is extended to contain *leng... | .. class:: mmap(fileno, length, tagname=None, \ access=ACCESS_DEFAULT, offset=0, *, trackfd=True)
**(Windows version)** Maps *length* bytes from the file specified by the
file descriptor *fileno*, and creates a mmap object. If *length* is larger
than the current size of the file, the file is extended to contain *leng... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9f1cd878-6aee-4a33-b4bb-b6c947914582 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,012 | supabase-export-v2 | 778439ac409b118a | ``None`` is returned to indicate success. An exception is raised when the call failed.
.. versionchanged:: 3.8
Previously, a nonzero value was returned on success; zero was returned
on error under Windows. A zero value was returned on success; an
exception was raised on error under Unix. | trusted_official_docs | CPython Docs | ``None`` is returned to indicate success. An exception is raised when the call failed.
.. versionchanged:: 3.8
Previously, a nonzero value was returned on success; zero was returned
on error under Windows. A zero value was returned on success; an
exception was raised on error under Unix. | ``None`` is returned to indicate success. An exception is raised when the call failed.
.. versionchanged:: 3.8
Previously, a nonzero value was returned on success; zero was returned
on error under Windows. A zero value was returned on success; an
exception was raised on error under Unix. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a1ee7d69-d961-40ef-8e77-3ac92009de4f | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,052 | supabase-export-v2 | 512fb2627a1ab05b | .. method:: write(bytes)
Write the bytes in *bytes* into memory at the current position of the
file pointer and return the number of bytes written (never less than
``len(bytes)``, since if the write fails, a :exc:`ValueError` will be
raised). The file position is updated to point after the bytes that
were written. ... | trusted_official_docs | CPython Docs | .. method:: write(bytes)
Write the bytes in *bytes* into memory at the current position of the
file pointer and return the number of bytes written (never less than
``len(bytes)``, since if the write fails, a :exc:`ValueError` will be
raised). The file position is updated to point after the bytes that
were written. ... | .. method:: write(bytes)
Write the bytes in *bytes* into memory at the current position of the
file pointer and return the number of bytes written (never less than
``len(bytes)``, since if the write fails, a :exc:`ValueError` will be
raised). The file position is updated to point after the bytes that
were written. ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a8fe58d1-cf37-4c74-8c78-673fba544670 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,048 | supabase-export-v2 | f41774560d2b18e7 | Return the length of the file, which can be larger than the size of the memory-mapped area. For an anonymous mapping, return its size.
.. versionchanged:: 3.15
Anonymous mappings are now supported on Unix. | trusted_official_docs | CPython Docs | Return the length of the file, which can be larger than the size of the memory-mapped area. For an anonymous mapping, return its size.
.. versionchanged:: 3.15
Anonymous mappings are now supported on Unix. | Return the length of the file, which can be larger than the size of the memory-mapped area. For an anonymous mapping, return its size.
.. versionchanged:: 3.15
Anonymous mappings are now supported on Unix. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ac1af1cd-b2db-46ca-833b-5d27e6aeb0d6 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,987 | supabase-export-v2 | 7513981978aa4119 | size mm[6:] = b" world!\n" # ... and read again using standard file methods mm.seek(0) print(mm.readline()) # prints b"Hello world!\n" # close the map mm.close()
:class:`~mmap.mmap` can also be used as a context manager in a :keyword:`with`
statement:: | trusted_official_docs | CPython Docs | size mm[6:] = b" world!\n" # ... and read again using standard file methods mm.seek(0) print(mm.readline()) # prints b"Hello world!\n" # close the map mm.close()
:class:`~mmap.mmap` can also be used as a context manager in a :keyword:`with`
statement:: | size mm[6:] = b" world!\n" # ... and read again using standard file methods mm.seek(0) print(mm.readline()) # prints b"Hello world!\n" # close the map mm.close()
:class:`~mmap.mmap` can also be used as a context manager in a :keyword:`with`
statement:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b03d4ee7-c396-42f1-a27f-d83b38f8b1b7 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 40,056 | supabase-export-v2 | 301b0e6a12d6ca67 | .. method:: write_byte(byte)
Write the integer *byte* into memory at the current
position of the file pointer; the file position is advanced by ``1``. If
the mmap was created with :const:`ACCESS_READ`, then writing to it will
raise a :exc:`TypeError` exception. | trusted_official_docs | CPython Docs | .. method:: write_byte(byte)
Write the integer *byte* into memory at the current
position of the file pointer; the file position is advanced by ``1``. If
the mmap was created with :const:`ACCESS_READ`, then writing to it will
raise a :exc:`TypeError` exception. | .. method:: write_byte(byte)
Write the integer *byte* into memory at the current
position of the file pointer; the file position is advanced by ``1``. If
the mmap was created with :const:`ACCESS_READ`, then writing to it will
raise a :exc:`TypeError` exception. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b3d42ab8-4f19-4bfa-a9eb-cb1095ee4063 | CPython Docs | file://datasets/cpython/Doc/library/mmap.rst | unknown | 13084950-4349-48cd-839e-57bc6814c258 | 39,969 | supabase-export-v2 | ff48410b0014a720 | the current size of the file, except that if the file is empty Windows raises an exception (you cannot create an empty mapping on Windows).
*tagname*, if specified and not ``None``, is a string giving a tag name for
the mapping. Windows allows you to have many different mappings against
the same file. If you specify ... | trusted_official_docs | CPython Docs | the current size of the file, except that if the file is empty Windows raises an exception (you cannot create an empty mapping on Windows).
*tagname*, if specified and not ``None``, is a string giving a tag name for
the mapping. Windows allows you to have many different mappings against
the same file. If you specify ... | the current size of the file, except that if the file is empty Windows raises an exception (you cannot create an empty mapping on Windows).
*tagname*, if specified and not ``None``, is a string giving a tag name for
the mapping. Windows allows you to have many different mappings against
the same file. If you specify ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.