Skip to content

Count leading zero bits in one CPU tick #19633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 102 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
36b718d
Count leading zero bits in one CPU tick
hnarkaytis Apr 21, 2020
5414a2f
Count leading zero bits in one CPU tick
hnarkaytis Apr 21, 2020
9b30a64
Merge branch 'count_leading_zeros' of github.com:hnarkaytis/cpython i…
hnarkaytis Apr 21, 2020
7e982dc
Add support for _MSC_
hnarkaytis Apr 21, 2020
debeb02
Workaround _MCVC_ support
hnarkaytis Apr 21, 2020
9c82ea7
bpo-34037: Add Python API whatsnew for loop.shutdown_default_executor…
aeros Apr 21, 2020
d3a8d61
Small improvements to the recipes and examples. (GH-19635)
rhettinger Apr 21, 2020
75bedbe
bpo-40327: Improve atomicity, speed, and memory efficiency of the ite…
rhettinger Apr 21, 2020
783a673
bpo-40164: Update macOS installer builds to use OpenSSL 1.1.1g. (GH-1…
ned-deily Apr 22, 2020
939e4c1
Workaround _MCVC_ inability to handle macro
hnarkaytis Apr 22, 2020
3a69f3c
bpo-38439: Add 256px IDLE icon (GH-17473)
hroncok Apr 22, 2020
b310700
bpo-38360: macOS: support alternate form of -isysroot flag (GH-16480)
jmroot Apr 22, 2020
bcc136b
bpo-38329: python.org macOS installers now update Current symlink (GH…
ned-deily Apr 22, 2020
9e2e2f3
Count leading zero bits with single CPU instruction
hnarkaytis Apr 22, 2020
22141ec
Replace __builtin_clz with __builtin_clzl
hnarkaytis Apr 22, 2020
886a15b
Change preprocessor check on ifdef MS_WINDOWS
hnarkaytis Apr 22, 2020
bd95e34
Add debug preprocessor check on ifdef MS_WINDOWS
hnarkaytis Apr 22, 2020
543e481
Fix typo and argument type
hnarkaytis Apr 22, 2020
9bee32b
bpo-40138: Fix Windows os.waitpid() for large exit code (GH-19637)
vstinner Apr 22, 2020
9b49893
bpo-40214: Fix ctypes WinDLL test with insecure flags (GH-19652)
zooba Apr 22, 2020
4454057
bpo-39562: Prevent collision of future and compiler flags (GH-19230)
isidentical Apr 22, 2020
39652cd
bpo-40260: Remove unnecessary newline in compile() call (GH-19641)
asottile Apr 22, 2020
a81849b
bpo-39939: Add str.removeprefix and str.removesuffix (GH-18939)
sweeneyde Apr 22, 2020
c5fc156
bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)
pablogsal Apr 22, 2020
3f8a58b
PEP 617: Only run the CI with the new parser (GH-19664)
pablogsal Apr 22, 2020
458004b
bpo-40334: Fix errors in parse_string.c with old compilers (GH-19666)
pablogsal Apr 22, 2020
ce0eacb
Add @pablogsal as code owner for pegen-related files (GH-19665)
pablogsal Apr 22, 2020
a25f3c4
bpo-40334: Fix builds outside the source directory and regenerate aut…
pablogsal Apr 23, 2020
1def775
bpo-40334: Rename PyConfig.use_peg to _use_peg_parser (GH-19670)
vstinner Apr 23, 2020
0b7829e
Compile extensions in test_peg_generator with C99 (GH-19668)
pablogsal Apr 23, 2020
ee40e4b
bpo-40334: Don't downcast from Py_ssize_t to int (GH-19671)
pablogsal Apr 23, 2020
1df5a9e
bpo-40334: Fix build errors and warnings in test_peg_generator (GH-19…
pablogsal Apr 23, 2020
8d1cbff
bpo-40334: Suppress all output in test_peg_generator (GH-19675)
lysnikolaou Apr 23, 2020
1221135
gdbinit: Use proper define syntax (GH-19557)
The-Compiler Apr 23, 2020
9e6a131
bpo-40370: Use the same compile and link args as the interpreter used…
pablogsal Apr 23, 2020
ebebb64
bpo-40334: Improve various PEG-Parser related stuff (GH-19669)
lysnikolaou Apr 23, 2020
02e4484
Update ga_new to use _PyArg_CheckPositional and _PyArg_NoKwnames (GH-…
corona10 Apr 23, 2020
d663d34
bpo-39983: Add test.support.print_warning() (GH-19683)
vstinner Apr 23, 2020
40ded94
bpo-40336: Refactor typing._SpecialForm (GH-19620)
serhiy-storchaka Apr 23, 2020
bc28805
bpo-40334: Use old compiler when compile mode is func_type (GH-19692)
gvanrossum Apr 23, 2020
3e89251
Fix broken mkdir -p call in regen-pegen (#19695)
gvanrossum Apr 23, 2020
50f28de
bpo-40334: Allow to run make regen-pegen without distutils (GH-19684)
pablogsal Apr 23, 2020
9f27dd3
Use Py_ssize_t instead of ssize_t (GH-19685)
pablogsal Apr 24, 2020
2510494
bpo-40048: Fix _PyCode_InitOpcache() error path (GH-19691)
vstinner Apr 24, 2020
4cc4d60
Expand the implementation comments (GH-19699)
rhettinger Apr 24, 2020
162c567
bpo-38061: os.closerange() uses closefrom() on FreeBSD (GH-19696)
vstinner Apr 24, 2020
e6f8abd
bpo-38061: subprocess uses closefrom() on FreeBSD (GH-19697)
vstinner Apr 24, 2020
24ffe70
bpo-40334: Rewrite test_c_parser to avoid memory leaks (GH-19694)
lysnikolaou Apr 24, 2020
503de71
bpo-40360: Deprecate lib2to3 module in light of PEP 617 (GH-19663)
carljm Apr 24, 2020
5aafa54
bpo-40340: Separate examples more clearly in the programming FAQ (GH-…
caje731 Apr 24, 2020
0e80b56
bpo-40334: Add What's New sections for PEP 617 and PEP 585 (GH-19704)
gvanrossum Apr 25, 2020
f828077
closes bpo-40385: Remove Tools/scripts/checkpyc.py (GH-19709)
ammaraskar Apr 25, 2020
d4f3923
bpo-40279: Add some error-handling to the module initialisation docs …
caje731 Apr 25, 2020
3c8a5b4
bpo-40275: Avoid importing asyncio in test.support (GH-19600)
serhiy-storchaka Apr 25, 2020
1699491
bpo-40275: Avoid importing socket in test.support (GH-19603)
serhiy-storchaka Apr 25, 2020
515fce4
bpo-40275: Avoid importing logging in test.support (GH-19601)
serhiy-storchaka Apr 25, 2020
ef33712
Fix typo in object.__format__ docs (GH-19504)
hroskes Apr 26, 2020
cfaf4c0
Fix typo in Lib/typing.py (GH-19717)
nfishe Apr 26, 2020
68b352a
bpo-40396: Support GenericAlias in the typing functions. (GH-19718)
serhiy-storchaka Apr 26, 2020
88499f1
bpo-40387: Improve queue join() example. (GH-19724)
rhettinger Apr 27, 2020
a494caa
bpo-40401: Remove duplicate pyhash.h include from pythoncore.vcxproj …
ammaraskar Apr 27, 2020
b54e46c
bpo-38387: Formally document PyDoc_STRVAR and PyDoc_STR macros (GH-16…
bsolomon1124 Apr 27, 2020
caf1aad
bpo-40348: Fix typos in the programming FAQ (GH-19729)
ZackerySpytz Apr 27, 2020
6292be7
bpo-40398: Fix typing.get_args() for special generic aliases. (GH-19720)
serhiy-storchaka Apr 27, 2020
4044c84
Add files in tests/test_peg_generator to the install target lists (GH…
pablogsal Apr 27, 2020
0169d30
bpo-40217: Ensure Py_VISIT(Py_TYPE(self)) is always called for PyType…
pablogsal Apr 27, 2020
91a5ae1
bpo-40217: Clean code in PyType_FromSpec_Alloc and add NEWS entry (GH…
pablogsal Apr 27, 2020
c5c4281
bpo-40375: Implement imaplib.IMAP4.unselect (GH-19712)
corona10 Apr 27, 2020
9adccc1
bpo-30966: Add multiprocessing.SimpleQueue.close() (GH-19735)
vstinner Apr 27, 2020
2b74c83
bpo-40334: Support CO_FUTURE_BARRY_AS_BDFL in the new parser (GH-19721)
pablogsal Apr 27, 2020
b94dbd7
bpo-40334: Support PyPARSE_DONT_IMPLY_DEDENT in the new parser (GH-19…
pablogsal Apr 27, 2020
1a27501
bpo-30966: concurrent.futures.Process.shutdown() closes queue (GH-19738)
vstinner Apr 27, 2020
5d1f32d
bpo-39995: Split test_concurrent_futures.test_crash() into sub-tests …
vstinner Apr 27, 2020
bc1c8af
Python 3.9.0a6
ambv Apr 27, 2020
d55133f
bpo-40334: Catch E_EOF error, when the tokenizer returns ERRORTOKEN (…
lysnikolaou Apr 28, 2020
3d53d87
bpo-40334: Don't skip test_parser:test_trigget_memory_error (GH-19744)
lysnikolaou Apr 28, 2020
5b9f498
bpo-40334: Refactor peg_generator to receive a Tokens file when build…
pablogsal Apr 28, 2020
d66685a
Merge tag 'v3.9.0a6'
ambv Apr 28, 2020
5da3526
Post 3.9.0a6
ambv Apr 28, 2020
7c59d7c
bpo-40421: Add pyframe.h header file (GH-19755)
vstinner Apr 28, 2020
b8f704d
bpo-40421: Add Include/cpython/code.h header file (GH-19756)
vstinner Apr 28, 2020
a42ca74
bpo-40421: Add PyFrame_GetCode() function (GH-19757)
vstinner Apr 28, 2020
d9a43e2
bpo-40025: Require _generate_next_value_ to be defined before members…
abbyonstott Apr 28, 2020
521c8d6
bpo-39966: Revert "bpo-25597: Ensure wraps' return value is used for …
tirkarthi Apr 28, 2020
6d86a23
bpo-40429: PyFrame_GetCode() result cannot be NULL (GH-19772)
vstinner Apr 28, 2020
5e8c691
bpo-32604: Add support for a "default" arg in channel_recv(). (GH-19770)
ericsnowcurrently Apr 28, 2020
8852ad4
bpo-40429: PyFrame_GetCode() now returns a strong reference (GH-19773)
vstinner Apr 28, 2020
49f70db
bpo-40431: Fix syntax typo in turtledemo (GH-19777)
hroncok Apr 29, 2020
f7bbf58
bpo-38880: List interpreters associated with a channel end (GH-17323)
LewisGaul Apr 29, 2020
cc0dc7e
bpo-40429: Refactor super_init() (GH-19776)
vstinner Apr 29, 2020
ae00a5a
bpo-40428: Remove PyTuple_ClearFreeList() function (GH-19769)
vstinner Apr 29, 2020
37af21b
bpo-40334: Fix shifting of nested f-strings in the new parser (GH-19771)
lysnikolaou Apr 29, 2020
4386b90
bpo-40429: PyThreadState_GetFrame() returns a strong ref (GH-19781)
vstinner Apr 29, 2020
2208134
bpo-40334: Explicitly cast to int in pegen.c to fix a compiler warnin…
pablogsal Apr 29, 2020
66abe98
bpo-40275: Move requires_hashdigest() to test.support.hashlib_helper …
shihai1991 Apr 29, 2020
7036477
bpo-40421: Add PyFrame_GetBack() function (GH-19765)
vstinner Apr 29, 2020
a4dfe8e
bpo-39995: Fix concurrent.futures _ThreadWakeup (GH-19760)
vstinner Apr 29, 2020
6d65087
bpo-40334: Disallow invalid single statements in the new parser (GH-1…
lysnikolaou Apr 29, 2020
bb4a585
bpo-40428: Remove references to Py*_ClearFreeList in the docs (GH-19783)
ZackerySpytz Apr 29, 2020
8f36fda
Count leading zero bits in one CPU tick
hnarkaytis Apr 21, 2020
64ecf0d
Rebase to master
hnarkaytis Apr 29, 2020
2908911
Cleanup merge conflict artifacts
hnarkaytis Apr 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Include/pytime.h @pganssle @abalkin

# Parser/Pgen
/Parser/pgen/ @pablogsal
/Parser/pegen/ @pablogsal
/Tools/peg_generator/ @pablogsal

# SQLite 3
**/*sqlite* @berkerpeksag
Expand Down
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: c
dist: xenial
dist: bionic

# To cache doc-building dependencies and C compiler output.
cache:
Expand Down Expand Up @@ -157,7 +157,9 @@ install:
before_script:
# -Og is much faster than -O0
- CFLAGS="${CFLAGS} -Og" ./configure --with-pydebug
- make -j4 regen-all
- eval "$(pyenv init -)"
- pyenv global 3.8
- PYTHON_FOR_REGEN=python3.8 make -j4 regen-all
- changes=`git status --porcelain`
- |
# Check for changes in regenerated files
Expand Down
5 changes: 0 additions & 5 deletions Doc/c-api/contextvars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ Context object management functions:
current context for the current thread. Returns ``0`` on success,
and ``-1`` on error.

.. c:function:: int PyContext_ClearFreeList()

Clear the context variable free list. Return the total number of
freed items. This function always succeeds.


Context variable functions:

Expand Down
7 changes: 0 additions & 7 deletions Doc/c-api/dict.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,3 @@ Dictionary Objects
for key, value in seq2:
if override or key not in a:
a[key] = value


.. c:function:: int PyDict_ClearFreeList()

Clear the free list. Return the total number of freed items.

.. versionadded:: 3.3
5 changes: 0 additions & 5 deletions Doc/c-api/float.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,3 @@ Floating Point Objects
.. c:function:: double PyFloat_GetMin()

Return the minimum normalized positive float *DBL_MIN* as C :c:type:`double`.

.. c:function:: int PyFloat_ClearFreeList()

Clear the float free list. Return the number of items that could not
be freed.
6 changes: 4 additions & 2 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,10 @@ All of the following functions must be called after :c:func:`Py_Initialize`.

.. c:function:: PyFrameObject* PyThreadState_GetFrame(PyThreadState *tstate)

Get the current frame of the Python thread state *tstate*. It can be
``NULL`` if no frame is currently executing.
Get the current frame of the Python thread state *tstate*.

Return a strong reference. Return ``NULL`` if no frame is currently
executing.

See also :c:func:`PyEval_GetFrame`.

Expand Down
10 changes: 10 additions & 0 deletions Doc/c-api/init_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,16 @@ PyConfig

:data:`sys._xoptions`.

.. c:member:: int _use_peg_parser

Enable PEG parser? Default: 1.

Set to 0 by :option:`-X oldparser <-X>` and :envvar:`PYTHONOLDPARSER`.

See also :pep:`617`.

.. deprecated-removed:: 3.9 3.10

If ``parse_argv`` is non-zero, ``argv`` arguments are parsed the same
way the regular Python parses command line arguments, and Python
arguments are stripped from ``argv``: see :ref:`Command Line Arguments
Expand Down
33 changes: 33 additions & 0 deletions Doc/c-api/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,39 @@ complete listing.
.. versionchanged:: 3.8
MSVC support was added.

.. c:macro:: PyDoc_STRVAR(name, str)

Creates a variable with name ``name`` that can be used in docstrings.
If Python is built without docstrings, the value will be empty.

Use :c:macro:`PyDoc_STRVAR` for docstrings to support building
Python without docstrings, as specified in :pep:`7`.

Example::

PyDoc_STRVAR(pop_doc, "Remove and return the rightmost element.");

static PyMethodDef deque_methods[] = {
// ...
{"pop", (PyCFunction)deque_pop, METH_NOARGS, pop_doc},
// ...
}

.. c:macro:: PyDoc_STR(str)

Creates a docstring for the given input string or an empty string
if docstrings are disabled.

Use :c:macro:`PyDoc_STR` in specifying docstrings to support
building Python without docstrings, as specified in :pep:`7`.

Example::

static PyMethodDef pysqlite_row_methods[] = {
{"keys", (PyCFunction)pysqlite_row_keys, METH_NOARGS,
PyDoc_STR("Returns the keys of the row.")},
{NULL, NULL}
};

.. _api-objects:

Expand Down
7 changes: 0 additions & 7 deletions Doc/c-api/list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,3 @@ List Objects

Return a new tuple object containing the contents of *list*; equivalent to
``tuple(list)``.


.. c:function:: int PyList_ClearFreeList()

Clear the free list. Return the total number of freed items.

.. versionadded:: 3.3
6 changes: 0 additions & 6 deletions Doc/c-api/method.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,3 @@ no longer available.
.. c:function:: PyObject* PyMethod_GET_SELF(PyObject *meth)

Macro version of :c:func:`PyMethod_Self` which avoids error checking.


.. c:function:: int PyMethod_ClearFreeList()

Clear the free list. Return the total number of freed items.

2 changes: 1 addition & 1 deletion Doc/c-api/module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ or request "multi-phase initialization" by returning the definition struct itsel
.. c:member:: const char *m_doc

Docstring for the module; usually a docstring variable created with
:c:func:`PyDoc_STRVAR` is used.
:c:macro:`PyDoc_STRVAR` is used.

.. c:member:: Py_ssize_t m_size

Expand Down
24 changes: 24 additions & 0 deletions Doc/c-api/reflection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,34 @@ Reflection
See also :c:func:`PyThreadState_GetFrame`.


.. c:function:: int PyFrame_GetBack(PyFrameObject *frame)

Get the *frame* next outer frame.

Return a strong reference, or ``NULL`` if *frame* has no outer frame.

*frame* must not be ``NULL``.

.. versionadded:: 3.9


.. c:function:: int PyFrame_GetCode(PyFrameObject *frame)

Get the *frame* code.

Return a strong reference.

*frame* must not be ``NULL``. The result (frame code) cannot be ``NULL``.

.. versionadded:: 3.9


.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)

Return the line number that *frame* is currently executing.

*frame* must not be ``NULL``.


.. c:function:: const char* PyEval_GetFuncName(PyObject *func)

Expand Down
7 changes: 0 additions & 7 deletions Doc/c-api/set.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,3 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
.. c:function:: int PySet_Clear(PyObject *set)

Empty an existing set of all elements.


.. c:function:: int PySet_ClearFreeList()

Clear the free list. Return the total number of freed items.

.. versionadded:: 3.3
5 changes: 0 additions & 5 deletions Doc/c-api/tuple.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ Tuple Objects
raises :exc:`MemoryError` or :exc:`SystemError`.


.. c:function:: int PyTuple_ClearFreeList()

Clear the free list. Return the total number of freed items.


Struct Sequence Objects
-----------------------

Expand Down
14 changes: 11 additions & 3 deletions Doc/extending/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -395,18 +395,26 @@ optionally followed by an import of the module::
}

/* Add a built-in module, before Py_Initialize */
PyImport_AppendInittab("spam", PyInit_spam);
if (PyImport_AppendInittab("spam", PyInit_spam) == -1) {
fprintf(stderr, "Error: could not extend in-built modules table\n");
exit(1);
}

/* Pass argv[0] to the Python interpreter */
Py_SetProgramName(program);

/* Initialize the Python interpreter. Required. */
/* Initialize the Python interpreter. Required.
If this step fails, it will be a fatal error. */
Py_Initialize();

/* Optionally import the module; alternatively,
import can be deferred until the embedded script
imports it. */
PyImport_ImportModule("spam");
pmodule = PyImport_ImportModule("spam");
if (!pmodule) {
PyErr_Print();
fprintf(stderr, "Error: could not import module 'spam'\n");
}

...

Expand Down
13 changes: 7 additions & 6 deletions Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -851,10 +851,11 @@ For integers, use the built-in :func:`int` type constructor, e.g. ``int('144')
e.g. ``float('144') == 144.0``.

By default, these interpret the number as decimal, so that ``int('0144') ==
144`` and ``int('0x144')`` raises :exc:`ValueError`. ``int(string, base)`` takes
the base to convert from as a second optional argument, so ``int('0x144', 16) ==
324``. If the base is specified as 0, the number is interpreted using Python's
rules: a leading '0o' indicates octal, and '0x' indicates a hex number.
144`` holds true, and ``int('0x144')`` raises :exc:`ValueError`. ``int(string,
base)`` takes the base to convert from as a second optional argument, so ``int(
'0x144', 16) == 324``. If the base is specified as 0, the number is interpreted
using Python's rules: a leading '0o' indicates octal, and '0x' indicates a hex
number.

Do not use the built-in function :func:`eval` if all you need is to convert
strings to numbers. :func:`eval` will be significantly slower and it presents a
Expand Down Expand Up @@ -1494,8 +1495,8 @@ to uppercase::

Here the ``UpperOut`` class redefines the ``write()`` method to convert the
argument string to uppercase before calling the underlying
``self.__outfile.write()`` method. All other methods are delegated to the
underlying ``self.__outfile`` object. The delegation is accomplished via the
``self._outfile.write()`` method. All other methods are delegated to the
underlying ``self._outfile`` object. The delegation is accomplished via the
``__getattr__`` method; consult :ref:`the language reference <attribute-access>`
for more information about controlling attribute access.

Expand Down
14 changes: 10 additions & 4 deletions Doc/library/2to3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
of *fixers* to transform it into valid Python 3.x code. The standard library
contains a rich set of fixers that will handle almost all code. 2to3 supporting
library :mod:`lib2to3` is, however, a flexible and generic library, so it is
possible to write your own fixers for 2to3. :mod:`lib2to3` could also be
adapted to custom applications in which Python code needs to be edited
automatically.
possible to write your own fixers for 2to3.


.. _2to3-using:
Expand Down Expand Up @@ -466,9 +464,17 @@ and off individually. They are described here in more detail.

--------------

.. deprecated:: 3.10
Python 3.9 will switch to a PEG parser (see :pep:`617`), and Python 3.10 may
include new language syntax that is not parsable by lib2to3's LL(1) parser.
The ``lib2to3`` module may be removed from the standard library in a future
Python version. Consider third-party alternatives such as `LibCST`_ or
`parso`_.

.. note::

The :mod:`lib2to3` API should be considered unstable and may change
drastically in the future.

.. XXX What is the public interface anyway?
.. _LibCST: https://libcst.readthedocs.io/
.. _parso: https://parso.readthedocs.io/
4 changes: 4 additions & 0 deletions Doc/library/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ overridden::
the next :class:`int` in sequence with the last :class:`int` provided, but
the way it does this is an implementation detail and may change.

.. note::

The :meth:`_generate_next_value_` method must be defined before any members.

Iteration
---------

Expand Down
9 changes: 9 additions & 0 deletions Doc/library/imaplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,15 @@ An :class:`IMAP4` instance has the following methods:

Unsubscribe from old mailbox.

.. method:: IMAP4.unselect()

:meth:`imaplib.IMAP4.unselect` frees server's resources associated with the
selected mailbox and returns the server to the authenticated
state. This command performs the same actions as :meth:`imaplib.IMAP4.close`, except
that no messages are permanently removed from the currently
selected mailbox.

.. versionadded:: 3.9

.. method:: IMAP4.xatom(name[, ...])

Expand Down
10 changes: 10 additions & 0 deletions Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,16 @@ For an example of the usage of queues for interprocess communication see

It is a simplified :class:`Queue` type, very close to a locked :class:`Pipe`.

.. method:: close()

Close the queue: release internal resources.

A queue must not be used anymore after it is closed. For example,
:meth:`get`, :meth:`put` and :meth:`empty` methods must no longer be
called.

.. versionadded:: 3.9

.. method:: empty()

Return ``True`` if the queue is empty, ``False`` otherwise.
Expand Down
28 changes: 12 additions & 16 deletions Doc/library/queue.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,32 +190,28 @@ fully processed by daemon consumer threads.

Example of how to wait for enqueued tasks to be completed::

import threading, queue

q = queue.Queue()

def worker():
while True:
item = q.get()
if item is None:
break
do_work(item)
print(f'Working on {item}')
print(f'Finished {item}')
q.task_done()

q = queue.Queue()
threads = []
for i in range(num_worker_threads):
t = threading.Thread(target=worker)
t.start()
threads.append(t)
# turn-on the worker thread
threading.Thread(target=worker, daemon=True).start()

for item in source():
# send thirty task requests to the worker
for item in range(30):
q.put(item)
print('All task requests sent\n', end='')

# block until all tasks are done
q.join()

# stop workers
for i in range(num_worker_threads):
q.put(None)
for t in threads:
t.join()
print('All work completed')


SimpleQueue Objects
Expand Down
Loading