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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
843c5346-49af-4fbe-af1b-58d94157c097 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,053 | supabase-export-v2 | c3a381974e24b2a9 | .. method:: HTTPConnection.set_debuglevel(level)
Set the debugging level. The default debug level is ``0``, meaning no
debugging output is printed. Any value greater than ``0`` will cause all
currently defined debug output to be printed to stdout. The ``debuglevel``
is passed to any new :class:`HTTPResponse` objects... | trusted_official_docs | CPython Docs | .. method:: HTTPConnection.set_debuglevel(level)
Set the debugging level. The default debug level is ``0``, meaning no
debugging output is printed. Any value greater than ``0`` will cause all
currently defined debug output to be printed to stdout. The ``debuglevel``
is passed to any new :class:`HTTPResponse` objects... | .. method:: HTTPConnection.set_debuglevel(level)
Set the debugging level. The default debug level is ``0``, meaning no
debugging output is printed. Any value greater than ``0`` will cause all
currently defined debug output to be printed to stdout. The ``debuglevel``
is passed to any new :class:`HTTPResponse` objects... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8a3c8ee8-3b12-41f0-8c3f-4d61da486ee6 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,050 | supabase-export-v2 | 9d07b4d7d1b65ba5 | Should be called after a request is sent to get the response from the server. Returns an :class:`HTTPResponse` instance.
.. versionchanged:: 3.5
If a :exc:`ConnectionError` or subclass is raised, the
:class:`HTTPConnection` object will be ready to reconnect when
a new request is sent. | trusted_official_docs | CPython Docs | Should be called after a request is sent to get the response from the server. Returns an :class:`HTTPResponse` instance.
.. versionchanged:: 3.5
If a :exc:`ConnectionError` or subclass is raised, the
:class:`HTTPConnection` object will be ready to reconnect when
a new request is sent. | Should be called after a request is sent to get the response from the server. Returns an :class:`HTTPResponse` instance.
.. versionchanged:: 3.5
If a :exc:`ConnectionError` or subclass is raised, the
:class:`HTTPConnection` object will be ready to reconnect when
a new request is sent. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8a941b63-271b-4a7e-b006-e702e3dd65a8 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,063 | supabase-export-v2 | 74bd9a9f88e3b651 | .. versionadded:: 3.2
.. versionchanged:: 3.12
HTTP CONNECT tunnelling requests use protocol HTTP/1.1, upgraded from
protocol HTTP/1.0. ``Host:`` HTTP headers are mandatory for HTTP/1.1, so
one will be automatically generated and transmitted if not provided in
the headers argument. | trusted_official_docs | CPython Docs | .. versionadded:: 3.2
.. versionchanged:: 3.12
HTTP CONNECT tunnelling requests use protocol HTTP/1.1, upgraded from
protocol HTTP/1.0. ``Host:`` HTTP headers are mandatory for HTTP/1.1, so
one will be automatically generated and transmitted if not provided in
the headers argument. | .. versionadded:: 3.2
.. versionchanged:: 3.12
HTTP CONNECT tunnelling requests use protocol HTTP/1.1, upgraded from
protocol HTTP/1.0. ``Host:`` HTTP headers are mandatory for HTTP/1.1, so
one will be automatically generated and transmitted if not provided in
the headers argument. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8f9f8875-85e5-4433-a8ec-89a24fd1ac12 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,131 | supabase-export-v2 | d407d7c5208a3e23 | Here is an example session that uses the ``GET`` method::
>>> import http.client
>>> conn = http.client.HTTPSConnection("www.python.org")
>>> conn.request("GET", "/")
>>> r1 = conn.getresponse()
>>> print(r1.status, r1.reason)
200 OK
>>> data1 = r1.read() # This will return entire content. >>> # The following exa... | trusted_official_docs | CPython Docs | Here is an example session that uses the ``GET`` method::
>>> import http.client
>>> conn = http.client.HTTPSConnection("www.python.org")
>>> conn.request("GET", "/")
>>> r1 = conn.getresponse()
>>> print(r1.status, r1.reason)
200 OK
>>> data1 = r1.read() # This will return entire content. >>> # The following exa... | Here is an example session that uses the ``GET`` method::
>>> import http.client
>>> conn = http.client.HTTPSConnection("www.python.org")
>>> conn.request("GET", "/")
>>> r1 = conn.getresponse()
>>> print(r1.status, r1.reason)
200 OK
>>> data1 = r1.read() # This will return entire content. >>> # The following exa... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
92fc2751-6a5a-43b8-8979-5e234358e12a | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,058 | supabase-export-v2 | d185b65e56fe84a1 | and *port* arguments specify the endpoint of the tunneled connection (i.e. the address included in the CONNECT request, *not* the address of the proxy server).
The *headers* argument should be a mapping of extra HTTP headers to send with
the CONNECT request. | trusted_official_docs | CPython Docs | and *port* arguments specify the endpoint of the tunneled connection (i.e. the address included in the CONNECT request, *not* the address of the proxy server).
The *headers* argument should be a mapping of extra HTTP headers to send with
the CONNECT request. | and *port* arguments specify the endpoint of the tunneled connection (i.e. the address included in the CONNECT request, *not* the address of the proxy server).
The *headers* argument should be a mapping of extra HTTP headers to send with
the CONNECT request. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
93a40cf0-030f-4d1b-9b38-2e607ef8dc71 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,042 | supabase-export-v2 | e45aaa651ea807fa | For example, to perform a ``GET`` request to ``https://docs.python.org/3/``::
>>> import http.client
>>> host = "docs.python.org"
>>> conn = http.client.HTTPSConnection(host)
>>> conn.request("GET", "/3/", headers={"Host": host})
>>> response = conn.getresponse()
>>> print(response.status, response.reason)
200 OK | trusted_official_docs | CPython Docs | For example, to perform a ``GET`` request to ``https://docs.python.org/3/``::
>>> import http.client
>>> host = "docs.python.org"
>>> conn = http.client.HTTPSConnection(host)
>>> conn.request("GET", "/3/", headers={"Host": host})
>>> response = conn.getresponse()
>>> print(response.status, response.reason)
200 OK | For example, to perform a ``GET`` request to ``https://docs.python.org/3/``::
>>> import http.client
>>> host = "docs.python.org"
>>> conn = http.client.HTTPSConnection(host)
>>> conn.request("GET", "/3/", headers={"Host": host})
>>> response = conn.getresponse()
>>> print(response.status, response.reason)
200 OK | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
93c279f0-c902-4458-8ae1-b2104b97f0cf | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 51,982 | supabase-export-v2 | 2f103ae2cc27a3c5 | .. versionchanged:: 3.8 This class now enables TLS 1.3 :attr:`ssl.SSLContext.post_handshake_auth` for the default *context* or when *cert_file* is passed with a custom *context*.
.. versionchanged:: 3.10
This class now sends an ALPN extension with protocol indicator
``http/1.1`` when no *context* is given. Custom *co... | trusted_official_docs | CPython Docs | .. versionchanged:: 3.8 This class now enables TLS 1.3 :attr:`ssl.SSLContext.post_handshake_auth` for the default *context* or when *cert_file* is passed with a custom *context*.
.. versionchanged:: 3.10
This class now sends an ALPN extension with protocol indicator
``http/1.1`` when no *context* is given. Custom *co... | .. versionchanged:: 3.8 This class now enables TLS 1.3 :attr:`ssl.SSLContext.post_handshake_auth` for the default *context* or when *cert_file* is passed with a custom *context*.
.. versionchanged:: 3.10
This class now sends an ALPN extension with protocol indicator
``http/1.1`` when no *context* is given. Custom *co... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
98b9df68-8d4e-4d1d-bd6a-84bde48fb765 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 51,983 | supabase-export-v2 | e1cc666da0ff0edb | 3.10 This class now sends an ALPN extension with protocol indicator ``http/1.1`` when no *context* is given. Custom *context* should set ALPN protocols with :meth:`~ssl.SSLContext.set_alpn_protocols`.
.. versionchanged:: 3.12
The deprecated *key_file*, *cert_file* and *check_hostname* parameters
have been removed. | trusted_official_docs | CPython Docs | 3.10 This class now sends an ALPN extension with protocol indicator ``http/1.1`` when no *context* is given. Custom *context* should set ALPN protocols with :meth:`~ssl.SSLContext.set_alpn_protocols`.
.. versionchanged:: 3.12
The deprecated *key_file*, *cert_file* and *check_hostname* parameters
have been removed. | 3.10 This class now sends an ALPN extension with protocol indicator ``http/1.1`` when no *context* is given. Custom *context* should set ALPN protocols with :meth:`~ssl.SSLContext.set_alpn_protocols`.
.. versionchanged:: 3.12
The deprecated *key_file*, *cert_file* and *check_hostname* parameters
have been removed. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9982f980-fa4b-4b1c-b3d5-2f94d4de1bfd | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,043 | supabase-export-v2 | 12a011362d4664ae | >>> import http.client >>> host = "docs.python.org" >>> conn = http.client.HTTPSConnection(host) >>> conn.request("GET", "/3/", headers={"Host": host}) >>> response = conn.getresponse() >>> print(response.status, response.reason) 200 OK
.. note::
Chunked transfer encoding has been added to the HTTP protocol
version 1... | trusted_official_docs | CPython Docs | >>> import http.client >>> host = "docs.python.org" >>> conn = http.client.HTTPSConnection(host) >>> conn.request("GET", "/3/", headers={"Host": host}) >>> response = conn.getresponse() >>> print(response.status, response.reason) 200 OK
.. note::
Chunked transfer encoding has been added to the HTTP protocol
version 1... | >>> import http.client >>> host = "docs.python.org" >>> conn = http.client.HTTPSConnection(host) >>> conn.request("GET", "/3/", headers={"Host": host}) >>> response = conn.getresponse() >>> print(response.status, response.reason) 200 OK
.. note::
Chunked transfer encoding has been added to the HTTP protocol
version 1... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a055193e-5967-4e1a-a572-40c6deeb9daa | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,069 | supabase-export-v2 | 1c3e90406a759294 | .. method:: HTTPConnection.connect()
Connect to the server specified when the object was created. By default,
this is called automatically when making a request if the client does not
already have a connection. | trusted_official_docs | CPython Docs | .. method:: HTTPConnection.connect()
Connect to the server specified when the object was created. By default,
this is called automatically when making a request if the client does not
already have a connection. | .. method:: HTTPConnection.connect()
Connect to the server specified when the object was created. By default,
this is called automatically when making a request if the client does not
already have a connection. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a1a2c858-5474-4ce3-9916-126074b9fbb2 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,059 | supabase-export-v2 | 4e20fb822a1208d9 | The *headers* argument should be a mapping of extra HTTP headers to send with the CONNECT request.
As HTTP/1.1 is used for HTTP CONNECT tunnelling request, `as per the RFC
<https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.6>`_, a HTTP ``Host:``
header must be provided, matching the authority-form of the requ... | trusted_official_docs | CPython Docs | The *headers* argument should be a mapping of extra HTTP headers to send with the CONNECT request.
As HTTP/1.1 is used for HTTP CONNECT tunnelling request, `as per the RFC
<https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.6>`_, a HTTP ``Host:``
header must be provided, matching the authority-form of the requ... | The *headers* argument should be a mapping of extra HTTP headers to send with the CONNECT request.
As HTTP/1.1 is used for HTTP CONNECT tunnelling request, `as per the RFC
<https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.6>`_, a HTTP ``Host:``
header must be provided, matching the authority-form of the requ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a1a3da2e-d0dc-4802-9339-ac2c24fb8fc8 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,037 | supabase-export-v2 | 31776f5fad0737f5 | be an absolute path to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>` (unless connecting to an HTTP proxy server or using the ``OPTIONS`` or ``CONNECT`` methods).
If *body* is specified, the specified data is sent after the headers are
finished. It may be a :class:`str`, a :term:`bytes-like object`, an
open... | trusted_official_docs | CPython Docs | be an absolute path to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>` (unless connecting to an HTTP proxy server or using the ``OPTIONS`` or ``CONNECT`` methods).
If *body* is specified, the specified data is sent after the headers are
finished. It may be a :class:`str`, a :term:`bytes-like object`, an
open... | be an absolute path to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>` (unless connecting to an HTTP proxy server or using the ``OPTIONS`` or ``CONNECT`` methods).
If *body* is specified, the specified data is sent after the headers are
finished. It may be a :class:`str`, a :term:`bytes-like object`, an
open... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a4e9ceff-6666-4672-8979-4b473c923206 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 51,993 | supabase-export-v2 | 725db178c596aae7 | value`` lines. The file has to be ready to read these field lines, so the first line should already be consumed before calling the function.
The following exceptions are raised as appropriate: | trusted_official_docs | CPython Docs | value`` lines. The file has to be ready to read these field lines, so the first line should already be consumed before calling the function.
The following exceptions are raised as appropriate: | value`` lines. The file has to be ready to read these field lines, so the first line should already be consumed before calling the function.
The following exceptions are raised as appropriate: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
aa6fa016-b43a-4b08-bfe9-1bb43f283b70 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,133 | supabase-export-v2 | c14c3825ad80b7cb | Here is an example session that uses the ``HEAD`` method. Note that the ``HEAD`` method never returns any data. ::
>>> import http.client
>>> conn = http.client.HTTPSConnection("www.python.org")
>>> conn.request("HEAD", "/")
>>> res = conn.getresponse()
>>> print(res.status, res.reason)
200 OK
>>> data = res.read... | trusted_official_docs | CPython Docs | Here is an example session that uses the ``HEAD`` method. Note that the ``HEAD`` method never returns any data. ::
>>> import http.client
>>> conn = http.client.HTTPSConnection("www.python.org")
>>> conn.request("HEAD", "/")
>>> res = conn.getresponse()
>>> print(res.status, res.reason)
200 OK
>>> data = res.read... | Here is an example session that uses the ``HEAD`` method. Note that the ``HEAD`` method never returns any data. ::
>>> import http.client
>>> conn = http.client.HTTPSConnection("www.python.org")
>>> conn.request("HEAD", "/")
>>> res = conn.getresponse()
>>> print(res.status, res.reason)
200 OK
>>> data = res.read... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b092ef15-f2b7-4f53-9f8d-07c7970dd1d3 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,039 | supabase-export-v2 | 00616955e1712f40 | <2616#section-14.23>` must be provided to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>` (unless connecting to an HTTP proxy server or using the ``OPTIONS`` or ``CONNECT`` methods).
If *headers* contains neither Content-Length nor Transfer-Encoding,
but there is a request body, one of those
header fields wi... | trusted_official_docs | CPython Docs | <2616#section-14.23>` must be provided to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>` (unless connecting to an HTTP proxy server or using the ``OPTIONS`` or ``CONNECT`` methods).
If *headers* contains neither Content-Length nor Transfer-Encoding,
but there is a request body, one of those
header fields wi... | <2616#section-14.23>` must be provided to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>` (unless connecting to an HTTP proxy server or using the ``OPTIONS`` or ``CONNECT`` methods).
If *headers* contains neither Content-Length nor Transfer-Encoding,
but there is a request body, one of those
header fields wi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b15333cf-58ef-4467-ac59-bd52f321a25f | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,137 | supabase-export-v2 | c390afc24b033dcc | that custom HTTP methods are also handled in :class:`urllib.request.Request` by setting the appropriate method attribute. Here is an example session that uses the ``PUT`` method::
>>> # This creates an HTTP request
>>> # with the content of BODY as the enclosed representation
>>> # for the resource http://localhost:8... | trusted_official_docs | CPython Docs | that custom HTTP methods are also handled in :class:`urllib.request.Request` by setting the appropriate method attribute. Here is an example session that uses the ``PUT`` method::
>>> # This creates an HTTP request
>>> # with the content of BODY as the enclosed representation
>>> # for the resource http://localhost:8... | that custom HTTP methods are also handled in :class:`urllib.request.Request` by setting the appropriate method attribute. Here is an example session that uses the ``PUT`` method::
>>> # This creates an HTTP request
>>> # with the content of BODY as the enclosed representation
>>> # for the resource http://localhost:8... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b41d0fae-fa1c-460a-9b1e-8b278cb737b2 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,045 | supabase-export-v2 | 1c3314a4985fcc32 | .. note::
Note that you must have read the whole response or call :meth:`close`
if :meth:`getresponse` raised an non-:exc:`ConnectionError` exception
before you can send a new request to the server. | trusted_official_docs | CPython Docs | .. note::
Note that you must have read the whole response or call :meth:`close`
if :meth:`getresponse` raised an non-:exc:`ConnectionError` exception
before you can send a new request to the server. | .. note::
Note that you must have read the whole response or call :meth:`close`
if :meth:`getresponse` raised an non-:exc:`ConnectionError` exception
before you can send a new request to the server. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c5b0ab7d-2c85-4c20-bdff-680602cd9227 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,087 | supabase-export-v2 | 043fff60dbe8c922 | a :term:`file object`, each call to ``.read()`` will result in a chunk. The method automatically signals the end of the chunk-encoded data immediately after *message_body*.
.. note:: Due to the chunked encoding specification, empty chunks
yielded by an iterator body will be ignored by the chunk-encoder. This is to avo... | trusted_official_docs | CPython Docs | a :term:`file object`, each call to ``.read()`` will result in a chunk. The method automatically signals the end of the chunk-encoded data immediately after *message_body*.
.. note:: Due to the chunked encoding specification, empty chunks
yielded by an iterator body will be ignored by the chunk-encoder. This is to avo... | a :term:`file object`, each call to ``.read()`` will result in a chunk. The method automatically signals the end of the chunk-encoded data immediately after *message_body*.
.. note:: Due to the chunked encoding specification, empty chunks
yielded by an iterator body will be ignored by the chunk-encoder. This is to avo... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c6377ace-b60d-42f5-ba1c-3d43cd5f9b15 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,132 | supabase-export-v2 | 119ba483af8b7d15 | invalid request >>> conn = http.client.HTTPSConnection("docs.python.org") >>> conn.request("GET", "/parrot.spam") >>> r2 = conn.getresponse() >>> print(r2.status, r2.reason) 404 Not Found >>> data2 = r2.read() >>> conn.close()
Here is an example session that uses the ``HEAD`` method. Note that the
``HEAD`` method never... | trusted_official_docs | CPython Docs | invalid request >>> conn = http.client.HTTPSConnection("docs.python.org") >>> conn.request("GET", "/parrot.spam") >>> r2 = conn.getresponse() >>> print(r2.status, r2.reason) 404 Not Found >>> data2 = r2.read() >>> conn.close()
Here is an example session that uses the ``HEAD`` method. Note that the
``HEAD`` method never... | invalid request >>> conn = http.client.HTTPSConnection("docs.python.org") >>> conn.request("GET", "/parrot.spam") >>> r2 = conn.getresponse() >>> print(r2.status, r2.reason) 404 Not Found >>> data2 = r2.read() >>> conn.close()
Here is an example session that uses the ``HEAD`` method. Note that the
``HEAD`` method never... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c93e4c89-0b67-43a0-ab7a-658e64979820 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 51,990 | supabase-export-v2 | ec32c0777f1ce49e | .. function:: parse_headers(fp)
Parse the headers from a file pointer *fp* representing a HTTP
request/response. The file has to be a :class:`~io.BufferedIOBase` reader
(i.e. not text) and must provide a valid :rfc:`5322` style header. | trusted_official_docs | CPython Docs | .. function:: parse_headers(fp)
Parse the headers from a file pointer *fp* representing a HTTP
request/response. The file has to be a :class:`~io.BufferedIOBase` reader
(i.e. not text) and must provide a valid :rfc:`5322` style header. | .. function:: parse_headers(fp)
Parse the headers from a file pointer *fp* representing a HTTP
request/response. The file has to be a :class:`~io.BufferedIOBase` reader
(i.e. not text) and must provide a valid :rfc:`5322` style header. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dd87ef07-7ba7-42f9-8b1a-c68aef15484c | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,080 | supabase-export-v2 | 7fe829d7e611e695 | As an alternative to using the :meth:`~HTTPConnection.request` method described above, you can also send your request step by step, by using the four functions below.
.. method:: HTTPConnection.putrequest(method, url, skip_host=False, \
skip_accept_encoding=False) | trusted_official_docs | CPython Docs | As an alternative to using the :meth:`~HTTPConnection.request` method described above, you can also send your request step by step, by using the four functions below.
.. method:: HTTPConnection.putrequest(method, url, skip_host=False, \
skip_accept_encoding=False) | As an alternative to using the :meth:`~HTTPConnection.request` method described above, you can also send your request step by step, by using the four functions below.
.. method:: HTTPConnection.putrequest(method, url, skip_host=False, \
skip_accept_encoding=False) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
de878f63-a9b2-4bbe-9d3a-5f9177b03e2b | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,081 | supabase-export-v2 | 5a1a1538927b6cd0 | .. method:: HTTPConnection.putrequest(method, url, skip_host=False, \ skip_accept_encoding=False)
This should be the first call after the connection to the server has been
made. It sends a line to the server consisting of the *method* string,
the *url* string, and the HTTP version (``HTTP/1.1``). To disable automatic... | trusted_official_docs | CPython Docs | .. method:: HTTPConnection.putrequest(method, url, skip_host=False, \ skip_accept_encoding=False)
This should be the first call after the connection to the server has been
made. It sends a line to the server consisting of the *method* string,
the *url* string, and the HTTP version (``HTTP/1.1``). To disable automatic... | .. method:: HTTPConnection.putrequest(method, url, skip_host=False, \ skip_accept_encoding=False)
This should be the first call after the connection to the server has been
made. It sends a line to the server consisting of the *method* string,
the *url* string, and the HTTP version (``HTTP/1.1``). To disable automatic... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e8357a67-84ca-4da2-afcc-1f2024e37eb4 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,036 | supabase-export-v2 | 59cbdb6d0a493c1a | .. method:: HTTPConnection.request(method, url, body=None, headers={}, *, \ encode_chunked=False)
This will send a request to the server using the HTTP request
method *method* and the request URI *url*. The provided *url* must be
an absolute path to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>`
(unless co... | trusted_official_docs | CPython Docs | .. method:: HTTPConnection.request(method, url, body=None, headers={}, *, \ encode_chunked=False)
This will send a request to the server using the HTTP request
method *method* and the request URI *url*. The provided *url* must be
an absolute path to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>`
(unless co... | .. method:: HTTPConnection.request(method, url, body=None, headers={}, *, \ encode_chunked=False)
This will send a request to the server using the HTTP request
method *method* and the request URI *url*. The provided *url* must be
an absolute path to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>`
(unless co... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e8c4e5e8-4ee1-4855-be33-914c7585f6e1 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,088 | supabase-export-v2 | bebf61a9397cb7cf | be ignored by the chunk-encoder. This is to avoid premature termination of the read of the request by the target server due to malformed encoding.
.. versionchanged:: 3.6
Added chunked encoding support and the *encode_chunked* parameter. | trusted_official_docs | CPython Docs | be ignored by the chunk-encoder. This is to avoid premature termination of the read of the request by the target server due to malformed encoding.
.. versionchanged:: 3.6
Added chunked encoding support and the *encode_chunked* parameter. | be ignored by the chunk-encoder. This is to avoid premature termination of the read of the request by the target server due to malformed encoding.
.. versionchanged:: 3.6
Added chunked encoding support and the *encode_chunked* parameter. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
eb064010-a042-4d6b-8db4-12ba7fe1d67d | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 51,969 | supabase-export-v2 | 579a16f46af50a8d | For example, the following calls all create instances that connect to the server at the same host and port::
>>> h1 = http.client.HTTPConnection('www.python.org')
>>> h2 = http.client.HTTPConnection('www.python.org:80')
>>> h3 = http.client.HTTPConnection('www.python.org', 80)
>>> h4 = http.client.HTTPConnection('ww... | trusted_official_docs | CPython Docs | For example, the following calls all create instances that connect to the server at the same host and port::
>>> h1 = http.client.HTTPConnection('www.python.org')
>>> h2 = http.client.HTTPConnection('www.python.org:80')
>>> h3 = http.client.HTTPConnection('www.python.org', 80)
>>> h4 = http.client.HTTPConnection('ww... | For example, the following calls all create instances that connect to the server at the same host and port::
>>> h1 = http.client.HTTPConnection('www.python.org')
>>> h2 = http.client.HTTPConnection('www.python.org:80')
>>> h3 = http.client.HTTPConnection('www.python.org', 80)
>>> h4 = http.client.HTTPConnection('ww... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f195b9fa-d981-47ae-9abe-8089712099b0 | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,070 | supabase-export-v2 | b094d8f3f2d4e870 | specified when the object was created. By default, this is called automatically when making a request if the client does not already have a connection.
.. audit-event:: http.client.connect self,host,port http.client.HTTPConnection.connect | trusted_official_docs | CPython Docs | specified when the object was created. By default, this is called automatically when making a request if the client does not already have a connection.
.. audit-event:: http.client.connect self,host,port http.client.HTTPConnection.connect | specified when the object was created. By default, this is called automatically when making a request if the client does not already have a connection.
.. audit-event:: http.client.connect self,host,port http.client.HTTPConnection.connect | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f32bb314-5904-4360-aac0-a78b6c42136e | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,040 | supabase-export-v2 | 136cef7c050d11eb | length. Any other type of *body* (files and iterables in general) will be chunk-encoded, and the Transfer-Encoding header will automatically be set instead of Content-Length.
The *encode_chunked* argument is only relevant if Transfer-Encoding is
specified in *headers*. If *encode_chunked* is ``False``, the
HTTPConnec... | trusted_official_docs | CPython Docs | length. Any other type of *body* (files and iterables in general) will be chunk-encoded, and the Transfer-Encoding header will automatically be set instead of Content-Length.
The *encode_chunked* argument is only relevant if Transfer-Encoding is
specified in *headers*. If *encode_chunked* is ``False``, the
HTTPConnec... | length. Any other type of *body* (files and iterables in general) will be chunk-encoded, and the Transfer-Encoding header will automatically be set instead of Content-Length.
The *encode_chunked* argument is only relevant if Transfer-Encoding is
specified in *headers*. If *encode_chunked* is ``False``, the
HTTPConnec... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f4d0853e-f5d0-491d-8216-e83a4f8e88cc | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 51,968 | supabase-export-v2 | cc2714a2d4cd67e9 | The optional *max_response_headers* parameter sets the maximum number of allowed response headers to help prevent denial-of-service attacks, otherwise the default value (100) is used.
For example, the following calls all create instances that connect to the server
at the same host and port:: | trusted_official_docs | CPython Docs | The optional *max_response_headers* parameter sets the maximum number of allowed response headers to help prevent denial-of-service attacks, otherwise the default value (100) is used.
For example, the following calls all create instances that connect to the server
at the same host and port:: | The optional *max_response_headers* parameter sets the maximum number of allowed response headers to help prevent denial-of-service attacks, otherwise the default value (100) is used.
For example, the following calls all create instances that connect to the server
at the same host and port:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f94ece3a-5d63-4b52-a6e0-fe471b83019b | CPython Docs | file://datasets/cpython/Doc/library/http.client.rst | unknown | bc479acd-6418-4552-a88b-2ce53eb05e19 | 52,038 | supabase-export-v2 | ddc947ca4187582b | by ``read()`` is sent as is. If *body* is an iterable, the elements of the iterable are sent as is until the iterable is exhausted.
The *headers* argument should be a mapping of extra HTTP headers to send
with the request. A :rfc:`Host header <2616#section-14.23>`
must be provided to conform with :rfc:`RFC 2616 §5.1.... | trusted_official_docs | CPython Docs | by ``read()`` is sent as is. If *body* is an iterable, the elements of the iterable are sent as is until the iterable is exhausted.
The *headers* argument should be a mapping of extra HTTP headers to send
with the request. A :rfc:`Host header <2616#section-14.23>`
must be provided to conform with :rfc:`RFC 2616 §5.1.... | by ``read()`` is sent as is. If *body* is an iterable, the elements of the iterable are sent as is until the iterable is exhausted.
The *headers* argument should be a mapping of extra HTTP headers to send
with the request. A :rfc:`Host header <2616#section-14.23>`
must be provided to conform with :rfc:`RFC 2616 §5.1.... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
07bc610a-0a0d-4388-9eaa-5e85aaea1c7c | CPython Docs | file://datasets/cpython/Doc/library/dialog.rst | unknown | c1f9e856-c971-4b17-b97b-b04ca3d29866 | 52,162 | supabase-export-v2 | 3a6481c8146eed2b | Native Load/Save Dialogs ------------------------
The following classes and functions provide file dialog windows that combine a
native look-and-feel with configuration options to customize behaviour. The following keyword arguments are applicable to the classes and functions
listed below: | trusted_official_docs | CPython Docs | Native Load/Save Dialogs ------------------------
The following classes and functions provide file dialog windows that combine a
native look-and-feel with configuration options to customize behaviour. The following keyword arguments are applicable to the classes and functions
listed below: | Native Load/Save Dialogs ------------------------
The following classes and functions provide file dialog windows that combine a
native look-and-feel with configuration options to customize behaviour. The following keyword arguments are applicable to the classes and functions
listed below: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
68423a2f-c7f4-4a9d-a1e1-f75b4c5ca37b | CPython Docs | file://datasets/cpython/Doc/library/dialog.rst | unknown | c1f9e856-c971-4b17-b97b-b04ca3d29866 | 52,172 | supabase-export-v2 | 5472c14dadf29d98 | below functions when called create a modal, native look-and-feel dialog, wait for the user's selection, then return the selected value(s) or ``None`` to the caller.
.. function:: askopenfile(mode="r", **options)
askopenfiles(mode="r", **options) | trusted_official_docs | CPython Docs | below functions when called create a modal, native look-and-feel dialog, wait for the user's selection, then return the selected value(s) or ``None`` to the caller.
.. function:: askopenfile(mode="r", **options)
askopenfiles(mode="r", **options) | below functions when called create a modal, native look-and-feel dialog, wait for the user's selection, then return the selected value(s) or ``None`` to the caller.
.. function:: askopenfile(mode="r", **options)
askopenfiles(mode="r", **options) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
757fffb6-6e0f-4c9b-871e-9bbca029185f | CPython Docs | file://datasets/cpython/Doc/library/dialog.rst | unknown | c1f9e856-c971-4b17-b97b-b04ca3d29866 | 52,148 | supabase-export-v2 | 49e707ff36efae58 | The :mod:`!tkinter.simpledialog` module contains convenience classes and functions for creating simple modal dialogs to get a value from the user.
.. function:: askfloat(title, prompt, **kw)
askinteger(title, prompt, **kw)
askstring(title, prompt, **kw) | trusted_official_docs | CPython Docs | The :mod:`!tkinter.simpledialog` module contains convenience classes and functions for creating simple modal dialogs to get a value from the user.
.. function:: askfloat(title, prompt, **kw)
askinteger(title, prompt, **kw)
askstring(title, prompt, **kw) | The :mod:`!tkinter.simpledialog` module contains convenience classes and functions for creating simple modal dialogs to get a value from the user.
.. function:: askfloat(title, prompt, **kw)
askinteger(title, prompt, **kw)
askstring(title, prompt, **kw) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cc44dca8-d340-4a7a-8e15-04dab3f1e58b | CPython Docs | file://datasets/cpython/Doc/library/dialog.rst | unknown | c1f9e856-c971-4b17-b97b-b04ca3d29866 | 52,225 | supabase-export-v2 | 6c8fc7a03ed911d7 | whether or not the selection points to a valid file that is not a directory. Confirmation is required if an already existing file is selected.
:mod:`!tkinter.commondialog` --- Dialog window templates
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | trusted_official_docs | CPython Docs | whether or not the selection points to a valid file that is not a directory. Confirmation is required if an already existing file is selected.
:mod:`!tkinter.commondialog` --- Dialog window templates
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | whether or not the selection points to a valid file that is not a directory. Confirmation is required if an already existing file is selected.
:mod:`!tkinter.commondialog` --- Dialog window templates
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
db71d32c-5ebe-42df-bb6f-402aa1daad4d | CPython Docs | file://datasets/cpython/Doc/library/dialog.rst | unknown | c1f9e856-c971-4b17-b97b-b04ca3d29866 | 52,163 | supabase-export-v2 | 6a13f9cf4d9bdb52 | windows that combine a native look-and-feel with configuration options to customize behaviour. The following keyword arguments are applicable to the classes and functions listed below:
| *parent* - the window to place the dialog on top of | trusted_official_docs | CPython Docs | windows that combine a native look-and-feel with configuration options to customize behaviour. The following keyword arguments are applicable to the classes and functions listed below:
| *parent* - the window to place the dialog on top of | windows that combine a native look-and-feel with configuration options to customize behaviour. The following keyword arguments are applicable to the classes and functions listed below:
| *parent* - the window to place the dialog on top of | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0349503b-e6d8-4706-af63-a3664e273392 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,287 | supabase-export-v2 | f87c1e1301a1983d | function of one argument that is used to extract a comparison key from each element in *iterable* (for example, ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key, reverse=True)[:n]``.
.. function:: nsmallest(n, iterable, key=None) | trusted_official_docs | CPython Docs | function of one argument that is used to extract a comparison key from each element in *iterable* (for example, ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key, reverse=True)[:n]``.
.. function:: nsmallest(n, iterable, key=None) | function of one argument that is used to extract a comparison key from each element in *iterable* (for example, ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key, reverse=True)[:n]``.
.. function:: nsmallest(n, iterable, key=None) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0c0ecb71-d740-42f2-a61a-ac7f7bdf8266 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,286 | supabase-export-v2 | fbff5145ab32fecd | .. function:: nlargest(n, iterable, key=None)
Return a list with the *n* largest elements from the dataset defined by
*iterable*. *key*, if provided, specifies a function of one argument that is
used to extract a comparison key from each element in *iterable* (for example,
``key=str.lower``). Equivalent to: ``sorted... | trusted_official_docs | CPython Docs | .. function:: nlargest(n, iterable, key=None)
Return a list with the *n* largest elements from the dataset defined by
*iterable*. *key*, if provided, specifies a function of one argument that is
used to extract a comparison key from each element in *iterable* (for example,
``key=str.lower``). Equivalent to: ``sorted... | .. function:: nlargest(n, iterable, key=None)
Return a list with the *n* largest elements from the dataset defined by
*iterable*. *key*, if provided, specifies a function of one argument that is
used to extract a comparison key from each element in *iterable* (for example,
``key=str.lower``). Equivalent to: ``sorted... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
144fb66b-ef24-4d2a-aa5b-f03cb1fd31fb | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,245 | supabase-export-v2 | 1393e902d608e143 | Like :meth:`list.sort`, this implementation uses only the ``<`` operator for comparisons, for both min-heaps and max-heaps.
In the API below, and in this documentation, the unqualified term *heap*
generally refers to a min-heap. The API for max-heaps is named using a ``_max`` suffix. | trusted_official_docs | CPython Docs | Like :meth:`list.sort`, this implementation uses only the ``<`` operator for comparisons, for both min-heaps and max-heaps.
In the API below, and in this documentation, the unqualified term *heap*
generally refers to a min-heap. The API for max-heaps is named using a ``_max`` suffix. | Like :meth:`list.sort`, this implementation uses only the ``<`` operator for comparisons, for both min-heaps and max-heaps.
In the API below, and in this documentation, the unqualified term *heap*
generally refers to a min-heap. The API for max-heaps is named using a ``_max`` suffix. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
18365c21-c5f5-4722-afb7-e76d30941fdb | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,275 | supabase-export-v2 | bae28d4cc7d9b4a8 | largest item from the max-heap *heap* and also push the new *item*. The max-heap size doesn't change. If the max-heap is empty, :exc:`IndexError` is raised.
The value returned may be smaller than the *item* added. Refer to the
analogous function :func:`heapreplace` for detailed usage notes. | trusted_official_docs | CPython Docs | largest item from the max-heap *heap* and also push the new *item*. The max-heap size doesn't change. If the max-heap is empty, :exc:`IndexError` is raised.
The value returned may be smaller than the *item* added. Refer to the
analogous function :func:`heapreplace` for detailed usage notes. | largest item from the max-heap *heap* and also push the new *item*. The max-heap size doesn't change. If the max-heap is empty, :exc:`IndexError` is raised.
The value returned may be smaller than the *item* added. Refer to the
analogous function :func:`heapreplace` for detailed usage notes. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1d55d518-1745-4d45-9f96-8a422a3c6f88 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,314 | supabase-export-v2 | f6b33af91637d15a | @dataclass(order=True) class PrioritizedItem: priority: int item: Any=field(compare=False)
The remaining challenges revolve around finding a pending task and making
changes to its priority or removing it entirely. Finding a task can be done
with a dictionary pointing to an entry in the queue. | trusted_official_docs | CPython Docs | @dataclass(order=True) class PrioritizedItem: priority: int item: Any=field(compare=False)
The remaining challenges revolve around finding a pending task and making
changes to its priority or removing it entirely. Finding a task can be done
with a dictionary pointing to an entry in the queue. | @dataclass(order=True) class PrioritizedItem: priority: int item: Any=field(compare=False)
The remaining challenges revolve around finding a pending task and making
changes to its priority or removing it entirely. Finding a task can be done
with a dictionary pointing to an entry in the queue. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
231a631a-e27f-4d61-9e06-94cb8e793146 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,330 | supabase-export-v2 | 65dd9b4b6e51a88d | same rate the first heap is melting. When the first heap completely vanishes, you switch heaps and start a new run. Clever and quite effective!
In a word, heaps are useful memory structures to know. I use them in a few
applications, and I think it is good to keep a 'heap' module around. :-) | trusted_official_docs | CPython Docs | same rate the first heap is melting. When the first heap completely vanishes, you switch heaps and start a new run. Clever and quite effective!
In a word, heaps are useful memory structures to know. I use them in a few
applications, and I think it is good to keep a 'heap' module around. :-) | same rate the first heap is melting. When the first heap completely vanishes, you switch heaps and start a new run. Clever and quite effective!
In a word, heaps are useful memory structures to know. I use them in a few
applications, and I think it is good to keep a 'heap' module around. :-) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
282be2b9-3423-4796-9f09-41a492c21532 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,260 | supabase-export-v2 | f80e672fa4649823 | If that isn't desired, consider using :func:`heappushpop` instead. Its push/pop combination returns the smaller of the two values, leaving the larger value on the heap.
For max-heaps, the following functions are provided: | trusted_official_docs | CPython Docs | If that isn't desired, consider using :func:`heappushpop` instead. Its push/pop combination returns the smaller of the two values, leaving the larger value on the heap.
For max-heaps, the following functions are provided: | If that isn't desired, consider using :func:`heappushpop` instead. Its push/pop combination returns the smaller of the two values, leaving the larger value on the heap.
For max-heaps, the following functions are provided: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
34a5c81a-95b6-4f1f-9acf-f9e64eac714d | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,317 | supabase-export-v2 | ee0a246895400d11 | entry_finder = {} # mapping of tasks to entries REMOVED = '<removed-task>' # placeholder for a removed task counter = itertools.count() # unique sequence count
def add_task(task, priority=0):
'Add a new task or update the priority of an existing task'
if task in entry_finder:
remove_task(task)
count = next(counter)... | trusted_official_docs | CPython Docs | entry_finder = {} # mapping of tasks to entries REMOVED = '<removed-task>' # placeholder for a removed task counter = itertools.count() # unique sequence count
def add_task(task, priority=0):
'Add a new task or update the priority of an existing task'
if task in entry_finder:
remove_task(task)
count = next(counter)... | entry_finder = {} # mapping of tasks to entries REMOVED = '<removed-task>' # placeholder for a removed task counter = itertools.count() # unique sequence count
def add_task(task, priority=0):
'Add a new task or update the priority of an existing task'
if task in entry_finder:
remove_task(task)
count = next(counter)... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3e0887df-f2d1-473b-b5e6-516c251f26c3 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,318 | supabase-export-v2 | b37b439835ffab2e | update the priority of an existing task' if task in entry_finder: remove_task(task) count = next(counter) entry = [priority, count, task] entry_finder[task] = entry heappush(pq, entry)
def remove_task(task):
'Mark an existing task as REMOVED. Raise KeyError if not found.'
entry = entry_finder.pop(task)
entry[-1] = R... | trusted_official_docs | CPython Docs | update the priority of an existing task' if task in entry_finder: remove_task(task) count = next(counter) entry = [priority, count, task] entry_finder[task] = entry heappush(pq, entry)
def remove_task(task):
'Mark an existing task as REMOVED. Raise KeyError if not found.'
entry = entry_finder.pop(task)
entry[-1] = R... | update the priority of an existing task' if task in entry_finder: remove_task(task) count = next(counter) entry = [priority, count, task] entry_finder[task] = entry heappush(pq, entry)
def remove_task(task):
'Mark an existing task as REMOVED. Raise KeyError if not found.'
entry = entry_finder.pop(task)
entry[-1] = R... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3ff38553-0cbd-40d5-8c3d-e04267583e49 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,319 | supabase-export-v2 | ceabf8f9821f32f5 | def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry = entry_finder.pop(task) entry[-1] = REMOVED
def pop_task():
'Remove and return the lowest priority task. Raise KeyError if empty.'
while pq:
priority, count, task = heappop(pq)
if task is not REMOVED:
del entry_finder[ta... | trusted_official_docs | CPython Docs | def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry = entry_finder.pop(task) entry[-1] = REMOVED
def pop_task():
'Remove and return the lowest priority task. Raise KeyError if empty.'
while pq:
priority, count, task = heappop(pq)
if task is not REMOVED:
del entry_finder[ta... | def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry = entry_finder.pop(task) entry[-1] = REMOVED
def pop_task():
'Remove and return the lowest priority task. Raise KeyError if empty.'
while pq:
priority, count, task = heappop(pq)
if task is not REMOVED:
del entry_finder[ta... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
424a8bd2-5257-43a9-9587-6d5e74eecccc | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,307 | supabase-export-v2 | ace4dfd6f8cf1715 | * Sort stability: how do you get two tasks with equal priorities to be returned in the order they were originally added?
* Tuple comparison breaks for (priority, task) pairs if the priorities are equal
and the tasks do not have a default comparison order. | trusted_official_docs | CPython Docs | * Sort stability: how do you get two tasks with equal priorities to be returned in the order they were originally added?
* Tuple comparison breaks for (priority, task) pairs if the priorities are equal
and the tasks do not have a default comparison order. | * Sort stability: how do you get two tasks with equal priorities to be returned in the order they were originally added?
* Tuple comparison breaks for (priority, task) pairs if the priorities are equal
and the tasks do not have a default comparison order. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
449cca8e-9194-42ed-8472-f9e24bc37c81 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,243 | supabase-export-v2 | f5d7ad05d8f45810 | (b) Textbooks often focus on max-heaps, due to their suitability for in-place sorting. Our implementation favors min-heaps as they better correspond to Python :class:`lists <list>`.
These two aspects make it possible to view the heap as a regular Python list
without surprises: ``heap[0]`` is the smallest item, and ``he... | trusted_official_docs | CPython Docs | (b) Textbooks often focus on max-heaps, due to their suitability for in-place sorting. Our implementation favors min-heaps as they better correspond to Python :class:`lists <list>`.
These two aspects make it possible to view the heap as a regular Python list
without surprises: ``heap[0]`` is the smallest item, and ``he... | (b) Textbooks often focus on max-heaps, due to their suitability for in-place sorting. Our implementation favors min-heaps as they better correspond to Python :class:`lists <list>`.
These two aspects make it possible to view the heap as a regular Python list
without surprises: ``heap[0]`` is the smallest item, and ``he... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
45029de8-de15-406d-af85-89de42583c7a | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,327 | supabase-export-v2 | a501289735efeeee | easily go into the heap. So, a heap is a good structure for implementing schedulers (this is what I used for my MIDI sequencer :-).
Various structures for implementing schedulers have been extensively studied,
and heaps are good for this, as they are reasonably speedy, the speed is almost
constant, and the worst case i... | trusted_official_docs | CPython Docs | easily go into the heap. So, a heap is a good structure for implementing schedulers (this is what I used for my MIDI sequencer :-).
Various structures for implementing schedulers have been extensively studied,
and heaps are good for this, as they are reasonably speedy, the speed is almost
constant, and the worst case i... | easily go into the heap. So, a heap is a good structure for implementing schedulers (this is what I used for my MIDI sequencer :-).
Various structures for implementing schedulers have been extensively studied,
and heaps are good for this, as they are reasonably speedy, the speed is almost
constant, and the worst case i... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4509cf85-93f0-4f58-bd43-d79979be389a | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,324 | supabase-export-v2 | 88432059fa403db3 | .. figure:: heapq-binary-tree.svg :class: invert-in-dark-mode :align: center :alt: Example (min-heap) binary tree.
In the tree above, each cell *k* is topping ``2*k+1`` and ``2*k+2``. In a usual
binary tournament we see in sports, each cell is the winner over the two cells
it tops, and we can trace the winner down the ... | trusted_official_docs | CPython Docs | .. figure:: heapq-binary-tree.svg :class: invert-in-dark-mode :align: center :alt: Example (min-heap) binary tree.
In the tree above, each cell *k* is topping ``2*k+1`` and ``2*k+2``. In a usual
binary tournament we see in sports, each cell is the winner over the two cells
it tops, and we can trace the winner down the ... | .. figure:: heapq-binary-tree.svg :class: invert-in-dark-mode :align: center :alt: Example (min-heap) binary tree.
In the tree above, each cell *k* is topping ``2*k+1`` and ``2*k+2``. In a usual
binary tournament we see in sports, each cell is the winner over the two cells
it tops, and we can trace the winner down the ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4e82f27d-0463-4ad6-b4af-1e75e34976c9 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,279 | supabase-export-v2 | 788fb362aaaf6532 | .. function:: merge(*iterables, key=None, reverse=False)
Merge multiple sorted inputs into a single sorted output (for example, merge
timestamped entries from multiple log files). Returns an :term:`iterator`
over the sorted values. | trusted_official_docs | CPython Docs | .. function:: merge(*iterables, key=None, reverse=False)
Merge multiple sorted inputs into a single sorted output (for example, merge
timestamped entries from multiple log files). Returns an :term:`iterator`
over the sorted values. | .. function:: merge(*iterables, key=None, reverse=False)
Merge multiple sorted inputs into a single sorted output (for example, merge
timestamped entries from multiple log files). Returns an :term:`iterator`
over the sorted values. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4fad8578-be1c-4695-a766-c3a3359446a4 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,316 | supabase-export-v2 | 5e230842a42c6437 | break the heap structure invariants. So, a possible solution is to mark the entry as removed and add a new entry with the revised priority::
pq = [] # list of entries arranged in a heap
entry_finder = {} # mapping of tasks to entries
REMOVED = '<removed-task>' # placeholder for a removed task
counter = itertools.cou... | trusted_official_docs | CPython Docs | break the heap structure invariants. So, a possible solution is to mark the entry as removed and add a new entry with the revised priority::
pq = [] # list of entries arranged in a heap
entry_finder = {} # mapping of tasks to entries
REMOVED = '<removed-task>' # placeholder for a removed task
counter = itertools.cou... | break the heap structure invariants. So, a possible solution is to mark the entry as removed and add a new entry with the revised priority::
pq = [] # list of entries arranged in a heap
entry_finder = {} # mapping of tasks to entries
REMOVED = '<removed-task>' # placeholder for a removed task
counter = itertools.cou... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
50957b05-8d2c-4634-9dda-f70b77d7c2ce | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,311 | supabase-export-v2 | 62f10722bbe564da | the order they were added. And since no two entry counts are the same, the tuple comparison will never attempt to directly compare two tasks.
Another solution to the problem of non-comparable tasks is to create a wrapper
class that ignores the task item and only compares the priority field:: | trusted_official_docs | CPython Docs | the order they were added. And since no two entry counts are the same, the tuple comparison will never attempt to directly compare two tasks.
Another solution to the problem of non-comparable tasks is to create a wrapper
class that ignores the task item and only compares the priority field:: | the order they were added. And since no two entry counts are the same, the tuple comparison will never attempt to directly compare two tasks.
Another solution to the problem of non-comparable tasks is to create a wrapper
class that ignores the task item and only compares the priority field:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
553fa653-3260-4400-ac21-5e208768d222 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,309 | supabase-export-v2 | e384824b75b3c63e | * If the priority of a task changes, how do you move it to a new position in the heap?
* Or if a pending task needs to be deleted, how do you find it and remove it
from the queue? | trusted_official_docs | CPython Docs | * If the priority of a task changes, how do you move it to a new position in the heap?
* Or if a pending task needs to be deleted, how do you find it and remove it
from the queue? | * If the priority of a task changes, how do you move it to a new position in the heap?
* Or if a pending task needs to be deleted, how do you find it and remove it
from the queue? | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5985e582-bdb9-49f7-97a0-73e20a32c7cf | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,258 | supabase-export-v2 | de43aa0dd026a9f0 | the smallest item from the *heap*, and also push the new *item*. The heap size doesn't change. If the heap is empty, :exc:`IndexError` is raised.
This one step operation is more efficient than a :func:`heappop` followed by
:func:`heappush` and can be more appropriate when using a fixed-size heap. The pop/push combinat... | trusted_official_docs | CPython Docs | the smallest item from the *heap*, and also push the new *item*. The heap size doesn't change. If the heap is empty, :exc:`IndexError` is raised.
This one step operation is more efficient than a :func:`heappop` followed by
:func:`heappush` and can be more appropriate when using a fixed-size heap. The pop/push combinat... | the smallest item from the *heap*, and also push the new *item*. The heap size doesn't change. If the heap is empty, :exc:`IndexError` is raised.
This one step operation is more efficient than a :func:`heappop` followed by
:func:`heappush` and can be more appropriate when using a fixed-size heap. The pop/push combinat... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5c7a31f3-840f-4975-9e24-c8f237f1e1af | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,241 | supabase-export-v2 | cda7a188297036b5 | the compared elements exist. Elements are counted from zero. The interesting property of a min-heap is that its smallest element is always the root, ``heap[0]``.
Max-heaps satisfy the reverse invariant: every parent node has a value
*greater* than any of its children. These are implemented as lists for which
``maxheap[... | trusted_official_docs | CPython Docs | the compared elements exist. Elements are counted from zero. The interesting property of a min-heap is that its smallest element is always the root, ``heap[0]``.
Max-heaps satisfy the reverse invariant: every parent node has a value
*greater* than any of its children. These are implemented as lists for which
``maxheap[... | the compared elements exist. Elements are counted from zero. The interesting property of a min-heap is that its smallest element is always the root, ``heap[0]``.
Max-heaps satisfy the reverse invariant: every parent node has a value
*greater* than any of its children. These are implemented as lists for which
``maxheap[... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5e1fe839-e2ef-4105-8186-9cf5133ea55c | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,323 | supabase-export-v2 | a83b9e0ad7866c17 | The strange invariant above is meant to be an efficient memory representation for a tournament. The numbers below are *k*, not ``a[k]``:
.. figure:: heapq-binary-tree.svg
:class: invert-in-dark-mode
:align: center
:alt: Example (min-heap) binary tree. | trusted_official_docs | CPython Docs | The strange invariant above is meant to be an efficient memory representation for a tournament. The numbers below are *k*, not ``a[k]``:
.. figure:: heapq-binary-tree.svg
:class: invert-in-dark-mode
:align: center
:alt: Example (min-heap) binary tree. | The strange invariant above is meant to be an efficient memory representation for a tournament. The numbers below are *k*, not ``a[k]``:
.. figure:: heapq-binary-tree.svg
:class: invert-in-dark-mode
:align: center
:alt: Example (min-heap) binary tree. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
60da7bc3-b787-43ab-8b02-1bad5e0ff30a | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,321 | supabase-export-v2 | f46636e419c5076a | Theory ------
Heaps are arrays for which ``a[k] <= a[2*k+1]`` and ``a[k] <= a[2*k+2]`` for all
*k*, counting elements from 0. For the sake of comparison, non-existing
elements are considered to be infinite. The interesting property of a heap is
that ``a[0]`` is always its smallest element. | trusted_official_docs | CPython Docs | Theory ------
Heaps are arrays for which ``a[k] <= a[2*k+1]`` and ``a[k] <= a[2*k+2]`` for all
*k*, counting elements from 0. For the sake of comparison, non-existing
elements are considered to be infinite. The interesting property of a heap is
that ``a[0]`` is always its smallest element. | Theory ------
Heaps are arrays for which ``a[k] <= a[2*k+1]`` and ``a[k] <= a[2*k+2]`` for all
*k*, counting elements from 0. For the sake of comparison, non-existing
elements are considered to be infinite. The interesting property of a heap is
that ``a[0]`` is always its smallest element. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
65fe58c4-dc49-4459-a8da-4e3ad1da607e | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,322 | supabase-export-v2 | 6d7629ebac776057 | the sake of comparison, non-existing elements are considered to be infinite. The interesting property of a heap is that ``a[0]`` is always its smallest element.
The strange invariant above is meant to be an efficient memory representation
for a tournament. The numbers below are *k*, not ``a[k]``: | trusted_official_docs | CPython Docs | the sake of comparison, non-existing elements are considered to be infinite. The interesting property of a heap is that ``a[0]`` is always its smallest element.
The strange invariant above is meant to be an efficient memory representation
for a tournament. The numbers below are *k*, not ``a[k]``: | the sake of comparison, non-existing elements are considered to be infinite. The interesting property of a heap is that ``a[0]`` is always its smallest element.
The strange invariant above is meant to be an efficient memory representation
for a tournament. The numbers below are *k*, not ``a[k]``: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6ab38398-04e8-4ae8-b754-e85391ad54ab | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,284 | supabase-export-v2 | 91584c32e727642d | elements are merged as if each comparison were reversed. To achieve behavior similar to ``sorted(itertools.chain(*iterables), reverse=True)``, all iterables must be sorted from largest to smallest.
.. versionchanged:: 3.5
Added the optional *key* and *reverse* parameters. | trusted_official_docs | CPython Docs | elements are merged as if each comparison were reversed. To achieve behavior similar to ``sorted(itertools.chain(*iterables), reverse=True)``, all iterables must be sorted from largest to smallest.
.. versionchanged:: 3.5
Added the optional *key* and *reverse* parameters. | elements are merged as if each comparison were reversed. To achieve behavior similar to ``sorted(itertools.chain(*iterables), reverse=True)``, all iterables must be sorted from largest to smallest.
.. versionchanged:: 3.5
Added the optional *key* and *reverse* parameters. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6e98d71b-2505-482d-8322-778d0ec6d130 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,306 | supabase-export-v2 | 08aa158130739058 | A `priority queue <https://en.wikipedia.org/wiki/Priority_queue>`_ is common use for a heap, and it presents several implementation challenges:
* Sort stability: how do you get two tasks with equal priorities to be returned
in the order they were originally added? | trusted_official_docs | CPython Docs | A `priority queue <https://en.wikipedia.org/wiki/Priority_queue>`_ is common use for a heap, and it presents several implementation challenges:
* Sort stability: how do you get two tasks with equal priorities to be returned
in the order they were originally added? | A `priority queue <https://en.wikipedia.org/wiki/Priority_queue>`_ is common use for a heap, and it presents several implementation challenges:
* Sort stability: how do you get two tasks with equal priorities to be returned
in the order they were originally added? | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
71259bd8-f4a1-404c-89a7-5a1d39c180c4 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,242 | supabase-export-v2 | 93dbe801cade263f | and ``maxheap[2*k+2] <= maxheap[k]`` for all *k* for which the compared elements exist. The root, ``maxheap[0]``, contains the *largest* element; ``heap.sort(reverse=True)`` maintains the max-heap invariant.
The :mod:`!heapq` API differs from textbook heap algorithms in two aspects: (a)
We use zero-based indexing. This... | trusted_official_docs | CPython Docs | and ``maxheap[2*k+2] <= maxheap[k]`` for all *k* for which the compared elements exist. The root, ``maxheap[0]``, contains the *largest* element; ``heap.sort(reverse=True)`` maintains the max-heap invariant.
The :mod:`!heapq` API differs from textbook heap algorithms in two aspects: (a)
We use zero-based indexing. This... | and ``maxheap[2*k+2] <= maxheap[k]`` for all *k* for which the compared elements exist. The root, ``maxheap[0]``, contains the *largest* element; ``heap.sort(reverse=True)`` maintains the max-heap invariant.
The :mod:`!heapq` API differs from textbook heap algorithms in two aspects: (a)
We use zero-based indexing. This... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
71d837dd-357a-47bd-a36b-f5f0c8fa7486 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,246 | supabase-export-v2 | 32e1e35fb6030c13 | API below, and in this documentation, the unqualified term *heap* generally refers to a min-heap. The API for max-heaps is named using a ``_max`` suffix.
To create a heap, use a list initialized as ``[]``, or transform an existing list
into a min-heap or max-heap using the :func:`heapify` or :func:`heapify_max`
functio... | trusted_official_docs | CPython Docs | API below, and in this documentation, the unqualified term *heap* generally refers to a min-heap. The API for max-heaps is named using a ``_max`` suffix.
To create a heap, use a list initialized as ``[]``, or transform an existing list
into a min-heap or max-heap using the :func:`heapify` or :func:`heapify_max`
functio... | API below, and in this documentation, the unqualified term *heap* generally refers to a min-heap. The API for max-heaps is named using a ``_max`` suffix.
To create a heap, use a list initialized as ``[]``, or transform an existing list
into a min-heap or max-heap using the :func:`heapify` or :func:`heapify_max`
functio... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7521d5d4-d94f-4dfb-b6b3-a92f8105bea5 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,332 | supabase-export-v2 | 87b47dd66fc828c3 | .. rubric:: Footnotes
.. [#] The disk balancing algorithms which are current, nowadays, are more annoying
than clever, and this is a consequence of the seeking capabilities of the disks. On devices which cannot seek, like big tape drives, the story was quite
different, and one had to be very clever to ensure (far in ... | trusted_official_docs | CPython Docs | .. rubric:: Footnotes
.. [#] The disk balancing algorithms which are current, nowadays, are more annoying
than clever, and this is a consequence of the seeking capabilities of the disks. On devices which cannot seek, like big tape drives, the story was quite
different, and one had to be very clever to ensure (far in ... | .. rubric:: Footnotes
.. [#] The disk balancing algorithms which are current, nowadays, are more annoying
than clever, and this is a consequence of the seeking capabilities of the disks. On devices which cannot seek, like big tape drives, the story was quite
different, and one had to be very clever to ensure (far in ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
77c3f490-bf52-4d5c-853b-e8a1638d1ed8 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,268 | supabase-export-v2 | 9cdaa610c1acf479 | .. function:: heappop_max(heap)
Pop and return the largest item from the max-heap *heap*, maintaining the
max-heap invariant. If the max-heap is empty, :exc:`IndexError` is raised. To access the largest item without popping it, use ``maxheap[0]``. | trusted_official_docs | CPython Docs | .. function:: heappop_max(heap)
Pop and return the largest item from the max-heap *heap*, maintaining the
max-heap invariant. If the max-heap is empty, :exc:`IndexError` is raised. To access the largest item without popping it, use ``maxheap[0]``. | .. function:: heappop_max(heap)
Pop and return the largest item from the max-heap *heap*, maintaining the
max-heap invariant. If the max-heap is empty, :exc:`IndexError` is raised. To access the largest item without popping it, use ``maxheap[0]``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7ede656d-5329-4901-9c28-9e898ed320b2 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,257 | supabase-export-v2 | d4366e87d6d67999 | .. function:: heapreplace(heap, item)
Pop and return the smallest item from the *heap*, and also push the new *item*. The heap size doesn't change. If the heap is empty, :exc:`IndexError` is raised. | trusted_official_docs | CPython Docs | .. function:: heapreplace(heap, item)
Pop and return the smallest item from the *heap*, and also push the new *item*. The heap size doesn't change. If the heap is empty, :exc:`IndexError` is raised. | .. function:: heapreplace(heap, item)
Pop and return the smallest item from the *heap*, and also push the new *item*. The heap size doesn't change. If the heap is empty, :exc:`IndexError` is raised. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
83e35d7f-d78c-4842-ad57-17beafed2c1d | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,297 | supabase-export-v2 | 917d16e4ea2a5614 | Other Applications ------------------
`Medians <https://en.wikipedia.org/wiki/Median>`_ are a measure of
central tendency for a set of numbers. In distributions skewed by
outliers, the median provides a more stable estimate than an average
(arithmetic mean). A running median is an `online algorithm
<https://en.wikipedi... | trusted_official_docs | CPython Docs | Other Applications ------------------
`Medians <https://en.wikipedia.org/wiki/Median>`_ are a measure of
central tendency for a set of numbers. In distributions skewed by
outliers, the median provides a more stable estimate than an average
(arithmetic mean). A running median is an `online algorithm
<https://en.wikipedi... | Other Applications ------------------
`Medians <https://en.wikipedia.org/wiki/Median>`_ are a measure of
central tendency for a set of numbers. In distributions skewed by
outliers, the median provides a more stable estimate than an average
(arithmetic mean). A running median is an `online algorithm
<https://en.wikipedi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
84a33be4-8517-4c3e-ac3a-bb5893882f74 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,240 | supabase-export-v2 | 215831d5eed65863 | which every parent node has a value less than or equal to any of its children. We refer to this condition as the heap invariant.
For min-heaps, this implementation uses lists for which
``heap[k] <= heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]`` for all *k* for which
the compared elements exist. Elements are counted from ... | trusted_official_docs | CPython Docs | which every parent node has a value less than or equal to any of its children. We refer to this condition as the heap invariant.
For min-heaps, this implementation uses lists for which
``heap[k] <= heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]`` for all *k* for which
the compared elements exist. Elements are counted from ... | which every parent node has a value less than or equal to any of its children. We refer to this condition as the heap invariant.
For min-heaps, this implementation uses lists for which
``heap[k] <= heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]`` for all *k* for which
the compared elements exist. Elements are counted from ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
86d4de8d-b630-4f85-a31b-efad832ac831 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,288 | supabase-export-v2 | d6fc53c631c5e819 | .. function:: nsmallest(n, iterable, key=None)
Return a list with the *n* smallest elements from the dataset defined by
*iterable*. *key*, if provided, specifies a function of one argument that is
used to extract a comparison key from each element in *iterable* (for example,
``key=str.lower``). Equivalent to: ``sort... | trusted_official_docs | CPython Docs | .. function:: nsmallest(n, iterable, key=None)
Return a list with the *n* smallest elements from the dataset defined by
*iterable*. *key*, if provided, specifies a function of one argument that is
used to extract a comparison key from each element in *iterable* (for example,
``key=str.lower``). Equivalent to: ``sort... | .. function:: nsmallest(n, iterable, key=None)
Return a list with the *n* smallest elements from the dataset defined by
*iterable*. *key*, if provided, specifies a function of one argument that is
used to extract a comparison key from each element in *iterable* (for example,
``key=str.lower``). Equivalent to: ``sort... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
88267d4d-805a-49de-bf57-f81faa03bca8 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,328 | supabase-export-v2 | b1946f0df5efecd2 | is not much different than the average case. However, there are other representations which are more efficient overall, yet the worst cases might be terrible.
Heaps are also very useful in big disk sorts. You most probably all know that a
big sort implies producing "runs" (which are pre-sorted sequences, whose size is
... | trusted_official_docs | CPython Docs | is not much different than the average case. However, there are other representations which are more efficient overall, yet the worst cases might be terrible.
Heaps are also very useful in big disk sorts. You most probably all know that a
big sort implies producing "runs" (which are pre-sorted sequences, whose size is
... | is not much different than the average case. However, there are other representations which are more efficient overall, yet the worst cases might be terrible.
Heaps are also very useful in big disk sorts. You most probably all know that a
big sort implies producing "runs" (which are pre-sorted sequences, whose size is
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8a2b6635-f4f0-4c0f-90d5-0896421c9a8f | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,299 | supabase-export-v2 | 7121fb323205b6c0 | size, the new median is the average of the tops of the two heaps; otherwise, the median is at the top of the larger heap::
def running_median(iterable):
"Yields the cumulative median of values seen so far." | trusted_official_docs | CPython Docs | size, the new median is the average of the tops of the two heaps; otherwise, the median is at the top of the larger heap::
def running_median(iterable):
"Yields the cumulative median of values seen so far." | size, the new median is the average of the tops of the two heaps; otherwise, the median is at the top of the larger heap::
def running_median(iterable):
"Yields the cumulative median of values seen so far." | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
91ace40c-f7d1-4b55-8bb6-fe7bbbd8c0d5 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,293 | supabase-export-v2 | 4db2147a02ebb6e8 | i in range(len(h))] ... >>> heapsort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0]) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
This is similar to ``sorted(iterable)``, but unlike :func:`sorted`, this
implementation is not stable. | trusted_official_docs | CPython Docs | i in range(len(h))] ... >>> heapsort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0]) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
This is similar to ``sorted(iterable)``, but unlike :func:`sorted`, this
implementation is not stable. | i in range(len(h))] ... >>> heapsort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0]) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
This is similar to ``sorted(iterable)``, but unlike :func:`sorted`, this
implementation is not stable. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
931f5fb3-4df1-4546-85c9-89635c89e0bb | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,310 | supabase-export-v2 | d31dac9881f41286 | * Or if a pending task needs to be deleted, how do you find it and remove it from the queue?
A solution to the first two challenges is to store entries as 3-element list
including the priority, an entry count, and the task. The entry count serves as
a tie-breaker so that two tasks with the same priority are returned in... | trusted_official_docs | CPython Docs | * Or if a pending task needs to be deleted, how do you find it and remove it from the queue?
A solution to the first two challenges is to store entries as 3-element list
including the priority, an entry count, and the task. The entry count serves as
a tie-breaker so that two tasks with the same priority are returned in... | * Or if a pending task needs to be deleted, how do you find it and remove it from the queue?
A solution to the first two challenges is to store entries as 3-element list
including the priority, an entry count, and the task. The entry count serves as
a tie-breaker so that two tasks with the same priority are returned in... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
93272f92-8ac6-42cd-8f3e-fab1069b7f27 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,259 | supabase-export-v2 | d96505492e2a2bd9 | and can be more appropriate when using a fixed-size heap. The pop/push combination always returns an element from the heap and replaces it with *item*.
The value returned may be larger than the *item* added. If that isn't
desired, consider using :func:`heappushpop` instead. Its push/pop
combination returns the smalle... | trusted_official_docs | CPython Docs | and can be more appropriate when using a fixed-size heap. The pop/push combination always returns an element from the heap and replaces it with *item*.
The value returned may be larger than the *item* added. If that isn't
desired, consider using :func:`heappushpop` instead. Its push/pop
combination returns the smalle... | and can be more appropriate when using a fixed-size heap. The pop/push combination always returns an element from the heap and replaces it with *item*.
The value returned may be larger than the *item* added. If that isn't
desired, consider using :func:`heappushpop` instead. Its push/pop
combination returns the smalle... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
934cb5bb-10d5-4ce0-9d5e-1a7b1602a431 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,253 | supabase-export-v2 | 514543816b312d3f | .. function:: heappop(heap)
Pop and return the smallest item from the *heap*, maintaining the min-heap
invariant. If the heap is empty, :exc:`IndexError` is raised. To access the
smallest item without popping it, use ``heap[0]``. | trusted_official_docs | CPython Docs | .. function:: heappop(heap)
Pop and return the smallest item from the *heap*, maintaining the min-heap
invariant. If the heap is empty, :exc:`IndexError` is raised. To access the
smallest item without popping it, use ``heap[0]``. | .. function:: heappop(heap)
Pop and return the smallest item from the *heap*, maintaining the min-heap
invariant. If the heap is empty, :exc:`IndexError` is raised. To access the
smallest item without popping it, use ``heap[0]``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
98497654-ae5d-41e1-9c4b-96ca72e37a3b | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,312 | supabase-export-v2 | c31742b1cedfe763 | Another solution to the problem of non-comparable tasks is to create a wrapper class that ignores the task item and only compares the priority field::
from dataclasses import dataclass, field
from typing import Any | trusted_official_docs | CPython Docs | Another solution to the problem of non-comparable tasks is to create a wrapper class that ignores the task item and only compares the priority field::
from dataclasses import dataclass, field
from typing import Any | Another solution to the problem of non-comparable tasks is to create a wrapper class that ignores the task item and only compares the priority field::
from dataclasses import dataclass, field
from typing import Any | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
98525af6-5e31-4f3a-b22d-b8d375df69d7 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,315 | supabase-export-v2 | 2662e0c5fb11a93f | making changes to its priority or removing it entirely. Finding a task can be done with a dictionary pointing to an entry in the queue.
Removing the entry or changing its priority is more difficult because it would
break the heap structure invariants. So, a possible solution is to mark the
entry as removed and add a ne... | trusted_official_docs | CPython Docs | making changes to its priority or removing it entirely. Finding a task can be done with a dictionary pointing to an entry in the queue.
Removing the entry or changing its priority is more difficult because it would
break the heap structure invariants. So, a possible solution is to mark the
entry as removed and add a ne... | making changes to its priority or removing it entirely. Finding a task can be done with a dictionary pointing to an entry in the queue.
Removing the entry or changing its priority is more difficult because it would
break the heap structure invariants. So, a possible solution is to mark the
entry as removed and add a ne... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9ae87f85-6de6-44e1-8a5d-ed370a306562 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,329 | supabase-export-v2 | 57e6496c267bfbcd | fit the current run, you'll produce runs which are twice the size of the memory for random input, and much better for input fuzzily ordered.
Moreover, if you output the 0'th item on disk and get an input which may not fit
in the current tournament (because the value "wins" over the last output value),
it cannot fit in ... | trusted_official_docs | CPython Docs | fit the current run, you'll produce runs which are twice the size of the memory for random input, and much better for input fuzzily ordered.
Moreover, if you output the 0'th item on disk and get an input which may not fit
in the current tournament (because the value "wins" over the last output value),
it cannot fit in ... | fit the current run, you'll produce runs which are twice the size of the memory for random input, and much better for input fuzzily ordered.
Moreover, if you output the 0'th item on disk and get an input which may not fit
in the current tournament (because the value "wins" over the last output value),
it cannot fit in ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9ed921eb-ff3b-410d-b8ec-42e0ed43dd3a | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,301 | supabase-export-v2 | f916a09245c0f709 | lo = [] # max-heap hi = [] # min-heap (same size as or one smaller than lo)
for x in iterable:
if len(lo) == len(hi):
heappush_max(lo, heappushpop(hi, x))
yield lo[0]
else:
heappush(hi, heappushpop_max(lo, x))
yield (lo[0] + hi[0]) / 2 | trusted_official_docs | CPython Docs | lo = [] # max-heap hi = [] # min-heap (same size as or one smaller than lo)
for x in iterable:
if len(lo) == len(hi):
heappush_max(lo, heappushpop(hi, x))
yield lo[0]
else:
heappush(hi, heappushpop_max(lo, x))
yield (lo[0] + hi[0]) / 2 | lo = [] # max-heap hi = [] # min-heap (same size as or one smaller than lo)
for x in iterable:
if len(lo) == len(hi):
heappush_max(lo, heappushpop(hi, x))
yield lo[0]
else:
heappush(hi, heappushpop_max(lo, x))
yield (lo[0] + hi[0]) / 2 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a0468c6f-8b38-4250-8d05-86f9e7559bfc | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,274 | supabase-export-v2 | 1b6d60f7605ebc3a | .. function:: heapreplace_max(heap, item)
Pop and return the largest item from the max-heap *heap* and also push the
new *item*. The max-heap size doesn't change. If the max-heap is empty,
:exc:`IndexError` is raised. | trusted_official_docs | CPython Docs | .. function:: heapreplace_max(heap, item)
Pop and return the largest item from the max-heap *heap* and also push the
new *item*. The max-heap size doesn't change. If the max-heap is empty,
:exc:`IndexError` is raised. | .. function:: heapreplace_max(heap, item)
Pop and return the largest item from the max-heap *heap* and also push the
new *item*. The max-heap size doesn't change. If the max-heap is empty,
:exc:`IndexError` is raised. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a3bd3634-c6c2-4cc9-ae42-396fce9badc3 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,325 | supabase-export-v2 | 80e4163444090eaf | rule becomes that a cell and the two cells it tops contain three different items, but the top cell "wins" over the two topped cells.
If this heap invariant is protected at all time, index 0 is clearly the overall
winner. The simplest algorithmic way to remove it and find the "next" winner is
to move some loser (let's s... | trusted_official_docs | CPython Docs | rule becomes that a cell and the two cells it tops contain three different items, but the top cell "wins" over the two topped cells.
If this heap invariant is protected at all time, index 0 is clearly the overall
winner. The simplest algorithmic way to remove it and find the "next" winner is
to move some loser (let's s... | rule becomes that a cell and the two cells it tops contain three different items, but the top cell "wins" over the two topped cells.
If this heap invariant is protected at all time, index 0 is clearly the overall
winner. The simplest algorithmic way to remove it and find the "next" winner is
to move some loser (let's s... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
aa32dc3c-264d-4edb-aa27-515227e5139a | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,298 | supabase-export-v2 | cfbc8d11debad905 | provides a more stable estimate than an average (arithmetic mean). A running median is an `online algorithm <https://en.wikipedia.org/wiki/Online_algorithm>`_ that updates continuously as new data arrives.
A running median can be efficiently implemented by balancing two heaps,
a max-heap for values at or below the midp... | trusted_official_docs | CPython Docs | provides a more stable estimate than an average (arithmetic mean). A running median is an `online algorithm <https://en.wikipedia.org/wiki/Online_algorithm>`_ that updates continuously as new data arrives.
A running median can be efficiently implemented by balancing two heaps,
a max-heap for values at or below the midp... | provides a more stable estimate than an average (arithmetic mean). A running median is an `online algorithm <https://en.wikipedia.org/wiki/Online_algorithm>`_ that updates continuously as new data arrives.
A running median can be efficiently implemented by balancing two heaps,
a max-heap for values at or below the midp... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b0b2e464-d20a-4641-b0b4-1e4f86ec0b34 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,283 | supabase-export-v2 | 83e7ec633fe37dea | function` of one argument that is used to extract a comparison key from each input element. The default value is ``None`` (compare the elements directly).
*reverse* is a boolean value. If set to ``True``, then the input elements
are merged as if each comparison were reversed. To achieve behavior similar
to ``sorted(i... | trusted_official_docs | CPython Docs | function` of one argument that is used to extract a comparison key from each input element. The default value is ``None`` (compare the elements directly).
*reverse* is a boolean value. If set to ``True``, then the input elements
are merged as if each comparison were reversed. To achieve behavior similar
to ``sorted(i... | function` of one argument that is used to extract a comparison key from each input element. The default value is ``None`` (compare the elements directly).
*reverse* is a boolean value. If set to ``True``, then the input elements
are merged as if each comparison were reversed. To achieve behavior similar
to ``sorted(i... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b6b85af2-e584-4e98-9073-698d40ae1998 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,289 | supabase-export-v2 | 97d3c125dd688766 | a function of one argument that is used to extract a comparison key from each element in *iterable* (for example, ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key)[:n]``.
The latter two functions perform best for smaller values of *n*. For larger
values, it is more efficient to use the :func:`sorted` funct... | trusted_official_docs | CPython Docs | a function of one argument that is used to extract a comparison key from each element in *iterable* (for example, ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key)[:n]``.
The latter two functions perform best for smaller values of *n*. For larger
values, it is more efficient to use the :func:`sorted` funct... | a function of one argument that is used to extract a comparison key from each element in *iterable* (for example, ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key)[:n]``.
The latter two functions perform best for smaller values of *n*. For larger
values, it is more efficient to use the :func:`sorted` funct... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bf9b959c-da98-406f-9f4c-4f70f9a48c83 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,247 | supabase-export-v2 | d9fd7d30e08f8162 | a heap, use a list initialized as ``[]``, or transform an existing list into a min-heap or max-heap using the :func:`heapify` or :func:`heapify_max` functions, respectively.
The following functions are provided for min-heaps: | trusted_official_docs | CPython Docs | a heap, use a list initialized as ``[]``, or transform an existing list into a min-heap or max-heap using the :func:`heapify` or :func:`heapify_max` functions, respectively.
The following functions are provided for min-heaps: | a heap, use a list initialized as ``[]``, or transform an existing list into a min-heap or max-heap using the :func:`heapify` or :func:`heapify_max` functions, respectively.
The following functions are provided for min-heaps: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c1a55efc-c1d8-401d-8e8e-ba13281d591f | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,244 | supabase-export-v2 | 1fae84d2fab271ab | make it possible to view the heap as a regular Python list without surprises: ``heap[0]`` is the smallest item, and ``heap.sort()`` maintains the heap invariant!
Like :meth:`list.sort`, this implementation uses only the ``<`` operator
for comparisons, for both min-heaps and max-heaps. | trusted_official_docs | CPython Docs | make it possible to view the heap as a regular Python list without surprises: ``heap[0]`` is the smallest item, and ``heap.sort()`` maintains the heap invariant!
Like :meth:`list.sort`, this implementation uses only the ``<`` operator
for comparisons, for both min-heaps and max-heaps. | make it possible to view the heap as a regular Python list without surprises: ``heap[0]`` is the smallest item, and ``heap.sort()`` maintains the heap invariant!
Like :meth:`list.sort`, this implementation uses only the ``<`` operator
for comparisons, for both min-heaps and max-heaps. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cd3b2d89-fe08-47a5-8075-84331fbebaa3 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,255 | supabase-export-v2 | a8c7679fb7af9ba4 | .. function:: heappushpop(heap, item)
Push *item* on the heap, then pop and return the smallest item from the
*heap*. The combined action runs more efficiently than :func:`heappush`
followed by a separate call to :func:`heappop`. | trusted_official_docs | CPython Docs | .. function:: heappushpop(heap, item)
Push *item* on the heap, then pop and return the smallest item from the
*heap*. The combined action runs more efficiently than :func:`heappush`
followed by a separate call to :func:`heappop`. | .. function:: heappushpop(heap, item)
Push *item* on the heap, then pop and return the smallest item from the
*heap*. The combined action runs more efficiently than :func:`heappush`
followed by a separate call to :func:`heappop`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d36fca3d-e1aa-4d4c-b2d1-196b634968ae | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,295 | supabase-export-v2 | 7e2d9daab3a023f9 | Heap elements can be tuples. This is useful for assigning comparison values (such as task priorities) alongside the main record being tracked::
>>> h = []
>>> heappush(h, (5, 'write code'))
>>> heappush(h, (7, 'release product'))
>>> heappush(h, (1, 'write spec'))
>>> heappush(h, (3, 'create tests'))
>>> heappop(h... | trusted_official_docs | CPython Docs | Heap elements can be tuples. This is useful for assigning comparison values (such as task priorities) alongside the main record being tracked::
>>> h = []
>>> heappush(h, (5, 'write code'))
>>> heappush(h, (7, 'release product'))
>>> heappush(h, (1, 'write spec'))
>>> heappush(h, (3, 'create tests'))
>>> heappop(h... | Heap elements can be tuples. This is useful for assigning comparison values (such as task priorities) alongside the main record being tracked::
>>> h = []
>>> heappush(h, (5, 'write code'))
>>> heappush(h, (7, 'release product'))
>>> heappush(h, (1, 'write spec'))
>>> heappush(h, (3, 'create tests'))
>>> heappop(h... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d7d26fe8-2e37-4a19-a319-97fbad98fe90 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,326 | supabase-export-v2 | 219e4c7ec8328f6c | is clearly logarithmic on the total number of items in the tree. By iterating over all items, you get an *O*\ (*n* log *n*) sort.
A nice feature of this sort is that you can efficiently insert new items while
the sort is going on, provided that the inserted items are not "better" than the
last 0'th element you extracte... | trusted_official_docs | CPython Docs | is clearly logarithmic on the total number of items in the tree. By iterating over all items, you get an *O*\ (*n* log *n*) sort.
A nice feature of this sort is that you can efficiently insert new items while
the sort is going on, provided that the inserted items are not "better" than the
last 0'th element you extracte... | is clearly logarithmic on the total number of items in the tree. By iterating over all items, you get an *O*\ (*n* log *n*) sort.
A nice feature of this sort is that you can efficiently insert new items while
the sort is going on, provided that the inserted items are not "better" than the
last 0'th element you extracte... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d96282ab-4b13-4929-ab42-03a95f1871c7 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,308 | supabase-export-v2 | f7166cf9e89b09f2 | * Tuple comparison breaks for (priority, task) pairs if the priorities are equal and the tasks do not have a default comparison order.
* If the priority of a task changes, how do you move it to a new position in
the heap? | trusted_official_docs | CPython Docs | * Tuple comparison breaks for (priority, task) pairs if the priorities are equal and the tasks do not have a default comparison order.
* If the priority of a task changes, how do you move it to a new position in
the heap? | * Tuple comparison breaks for (priority, task) pairs if the priorities are equal and the tasks do not have a default comparison order.
* If the priority of a task changes, how do you move it to a new position in
the heap? | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
da6eb969-634b-4161-9b16-164f5b7ce6c9 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,280 | supabase-export-v2 | b45586d8e6b1f682 | Merge multiple sorted inputs into a single sorted output (for example, merge timestamped entries from multiple log files). Returns an :term:`iterator` over the sorted values.
Similar to ``sorted(itertools.chain(*iterables))`` but returns an iterable, does
not pull the data into memory all at once, and assumes that eac... | trusted_official_docs | CPython Docs | Merge multiple sorted inputs into a single sorted output (for example, merge timestamped entries from multiple log files). Returns an :term:`iterator` over the sorted values.
Similar to ``sorted(itertools.chain(*iterables))`` but returns an iterable, does
not pull the data into memory all at once, and assumes that eac... | Merge multiple sorted inputs into a single sorted output (for example, merge timestamped entries from multiple log files). Returns an :term:`iterator` over the sorted values.
Similar to ``sorted(itertools.chain(*iterables))`` but returns an iterable, does
not pull the data into memory all at once, and assumes that eac... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dec91a2a-3f76-465d-9da4-318ba42b8730 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,294 | supabase-export-v2 | ea14483b88ed51c2 | This is similar to ``sorted(iterable)``, but unlike :func:`sorted`, this implementation is not stable.
Heap elements can be tuples. This is useful for assigning comparison values
(such as task priorities) alongside the main record being tracked:: | trusted_official_docs | CPython Docs | This is similar to ``sorted(iterable)``, but unlike :func:`sorted`, this implementation is not stable.
Heap elements can be tuples. This is useful for assigning comparison values
(such as task priorities) alongside the main record being tracked:: | This is similar to ``sorted(iterable)``, but unlike :func:`sorted`, this implementation is not stable.
Heap elements can be tuples. This is useful for assigning comparison values
(such as task priorities) alongside the main record being tracked:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e70c6aa8-6928-495e-8202-1336f89cc146 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,271 | supabase-export-v2 | 999d160f8e713875 | .. function:: heappushpop_max(heap, item)
Push *item* on the max-heap *heap*, then pop and return the largest item
from *heap*. The combined action runs more efficiently than :func:`heappush_max`
followed by a separate call to :func:`heappop_max`. | trusted_official_docs | CPython Docs | .. function:: heappushpop_max(heap, item)
Push *item* on the max-heap *heap*, then pop and return the largest item
from *heap*. The combined action runs more efficiently than :func:`heappush_max`
followed by a separate call to :func:`heappop_max`. | .. function:: heappushpop_max(heap, item)
Push *item* on the max-heap *heap*, then pop and return the largest item
from *heap*. The combined action runs more efficiently than :func:`heappush_max`
followed by a separate call to :func:`heappop_max`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e7c78564-594e-42cc-b8a1-e2d295615043 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,282 | supabase-export-v2 | 1a5b0c4d3e1655da | Has two optional arguments which must be specified as keyword arguments.
*key* specifies a :term:`key function` of one argument that is used to
extract a comparison key from each input element. The default value is
``None`` (compare the elements directly). | trusted_official_docs | CPython Docs | Has two optional arguments which must be specified as keyword arguments.
*key* specifies a :term:`key function` of one argument that is used to
extract a comparison key from each input element. The default value is
``None`` (compare the elements directly). | Has two optional arguments which must be specified as keyword arguments.
*key* specifies a :term:`key function` of one argument that is used to
extract a comparison key from each input element. The default value is
``None`` (compare the elements directly). | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f626b614-68aa-437a-8eae-337c28d6fa2c | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,292 | supabase-export-v2 | 3204c550478ec995 | A `heapsort <https://en.wikipedia.org/wiki/Heapsort>`_ can be implemented by pushing all values onto a heap and then popping off the smallest values one at a time::
>>> def heapsort(iterable):
... h = []
... for value in iterable:
... heappush(h, value)
... return [heappop(h) for i in range(len(h))]
... >>> heapso... | trusted_official_docs | CPython Docs | A `heapsort <https://en.wikipedia.org/wiki/Heapsort>`_ can be implemented by pushing all values onto a heap and then popping off the smallest values one at a time::
>>> def heapsort(iterable):
... h = []
... for value in iterable:
... heappush(h, value)
... return [heappop(h) for i in range(len(h))]
... >>> heapso... | A `heapsort <https://en.wikipedia.org/wiki/Heapsort>`_ can be implemented by pushing all values onto a heap and then popping off the smallest values one at a time::
>>> def heapsort(iterable):
... h = []
... for value in iterable:
... heappush(h, value)
... return [heappop(h) for i in range(len(h))]
... >>> heapso... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fa554ee1-5b9f-4221-a1f4-79a452ec0bdb | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,239 | supabase-export-v2 | 72474432bf93b96f | This module provides an implementation of the heap queue algorithm, also known as the priority queue algorithm.
Min-heaps are binary trees for which every parent node has a value less than
or equal to any of its children. We refer to this condition as the heap invariant. | trusted_official_docs | CPython Docs | This module provides an implementation of the heap queue algorithm, also known as the priority queue algorithm.
Min-heaps are binary trees for which every parent node has a value less than
or equal to any of its children. We refer to this condition as the heap invariant. | This module provides an implementation of the heap queue algorithm, also known as the priority queue algorithm.
Min-heaps are binary trees for which every parent node has a value less than
or equal to any of its children. We refer to this condition as the heap invariant. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fa6c03e9-758f-43a0-b1f5-a5d35fe67e66 | CPython Docs | file://datasets/cpython/Doc/library/heapq.rst | unknown | 02576e3e-49d3-4b80-960f-7cb410eaf88b | 52,281 | supabase-export-v2 | 01cc05bdd6ce8c45 | iterable, does not pull the data into memory all at once, and assumes that each of the input streams is already sorted (smallest to largest).
Has two optional arguments which must be specified as keyword arguments. | trusted_official_docs | CPython Docs | iterable, does not pull the data into memory all at once, and assumes that each of the input streams is already sorted (smallest to largest).
Has two optional arguments which must be specified as keyword arguments. | iterable, does not pull the data into memory all at once, and assumes that each of the input streams is already sorted (smallest to largest).
Has two optional arguments which must be specified as keyword arguments. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
011cc9f1-53c3-4132-99ee-e1f74eaca583 | CPython Docs | file://datasets/cpython/Doc/library/profiling.tracing.rst | unknown | 5eeddcb2-78dd-4fdd-aa68-f074d2e579f6 | 52,407 | supabase-export-v2 | 0b46b167047ec75d | Create a :class:`pstats.Stats` object from the current profile and print the results to standard output.
The *sort* argument specifies the sorting order. It accepts a single
key or a tuple of keys for multi-level sorting, using the same values
as :meth:`pstats.Stats.sort_stats`. | trusted_official_docs | CPython Docs | Create a :class:`pstats.Stats` object from the current profile and print the results to standard output.
The *sort* argument specifies the sorting order. It accepts a single
key or a tuple of keys for multi-level sorting, using the same values
as :meth:`pstats.Stats.sort_stats`. | Create a :class:`pstats.Stats` object from the current profile and print the results to standard output.
The *sort* argument specifies the sorting order. It accepts a single
key or a tuple of keys for multi-level sorting, using the same values
as :meth:`pstats.Stats.sort_stats`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
08062d16-ab4e-446a-ace5-f32bb2d984e5 | CPython Docs | file://datasets/cpython/Doc/library/profiling.tracing.rst | unknown | 5eeddcb2-78dd-4fdd-aa68-f074d2e579f6 | 52,350 | supabase-export-v2 | ecd58e903877cbbf | What is the complete call graph of my program? - Which functions are called by a particular function? - Are there unexpected function calls happening?
Call count statistics can identify bugs (surprising counts) and inline
expansion opportunities (high call counts). Internal time statistics reveal
"hot loops" that warra... | trusted_official_docs | CPython Docs | What is the complete call graph of my program? - Which functions are called by a particular function? - Are there unexpected function calls happening?
Call count statistics can identify bugs (surprising counts) and inline
expansion opportunities (high call counts). Internal time statistics reveal
"hot loops" that warra... | What is the complete call graph of my program? - Which functions are called by a particular function? - Are there unexpected function calls happening?
Call count statistics can identify bugs (surprising counts) and inline
expansion opportunities (high call counts). Internal time statistics reveal
"hot loops" that warra... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0dfb4f10-2839-4ae0-b09b-947eb0b9519f | CPython Docs | file://datasets/cpython/Doc/library/profiling.tracing.rst | unknown | 5eeddcb2-78dd-4fdd-aa68-f074d2e579f6 | 52,361 | supabase-export-v2 | 48e076d45d809835 | .. option:: -s <sort_order>
Sort the output by the specified key. This accepts any of the sort keys
recognized by :meth:`pstats.Stats.sort_stats`, such as ``cumulative``,
``time``, ``calls``, or ``name``. This option only applies when
:option:`-o <profiling.tracing -o>` is not specified. | trusted_official_docs | CPython Docs | .. option:: -s <sort_order>
Sort the output by the specified key. This accepts any of the sort keys
recognized by :meth:`pstats.Stats.sort_stats`, such as ``cumulative``,
``time``, ``calls``, or ``name``. This option only applies when
:option:`-o <profiling.tracing -o>` is not specified. | .. option:: -s <sort_order>
Sort the output by the specified key. This accepts any of the sort keys
recognized by :meth:`pstats.Stats.sort_stats`, such as ``cumulative``,
``time``, ``calls``, or ``name``. This option only applies when
:option:`-o <profiling.tracing -o>` is not specified. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
27c0b36e-6cee-47e0-bdfc-b6a38aee8278 | CPython Docs | file://datasets/cpython/Doc/library/profiling.tracing.rst | unknown | 5eeddcb2-78dd-4fdd-aa68-f074d2e579f6 | 52,397 | supabase-export-v2 | 4591b7d71020575a | number representing the current time. If the timer returns integers, use *timeunit* to specify the duration of one time unit (for example, ``0.001`` for milliseconds).
The *subcalls* argument controls whether the profiler tracks call
relationships between functions. The *builtins* argument controls whether
built-in f... | trusted_official_docs | CPython Docs | number representing the current time. If the timer returns integers, use *timeunit* to specify the duration of one time unit (for example, ``0.001`` for milliseconds).
The *subcalls* argument controls whether the profiler tracks call
relationships between functions. The *builtins* argument controls whether
built-in f... | number representing the current time. If the timer returns integers, use *timeunit* to specify the duration of one time unit (for example, ``0.001`` for milliseconds).
The *subcalls* argument controls whether the profiler tracks call
relationships between functions. The *builtins* argument controls whether
built-in f... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2df39339-6977-4f44-a17d-8104dba02801 | CPython Docs | file://datasets/cpython/Doc/library/profiling.tracing.rst | unknown | 5eeddcb2-78dd-4fdd-aa68-f074d2e579f6 | 52,424 | supabase-export-v2 | 97539f2336d073cc | timer function must return a single number representing the current time. If it returns integers, also specify *timeunit* to indicate the duration of one unit::
# Timer returns time in milliseconds
pr = profiling.tracing.Profile(my_ms_timer, 0.001) | trusted_official_docs | CPython Docs | timer function must return a single number representing the current time. If it returns integers, also specify *timeunit* to indicate the duration of one unit::
# Timer returns time in milliseconds
pr = profiling.tracing.Profile(my_ms_timer, 0.001) | timer function must return a single number representing the current time. If it returns integers, also specify *timeunit* to indicate the duration of one unit::
# Timer returns time in milliseconds
pr = profiling.tracing.Profile(my_ms_timer, 0.001) | 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.