PEP 509: fix typo reported by Jim J. Jewett

This commit is contained in:
Victor Stinner 2016-04-21 00:37:56 +02:00
parent 7690a00d47
commit b0f0a095d0
1 changed files with 12 additions and 11 deletions

View File

@ -38,9 +38,9 @@ The speedup of optimizations depends on the speed of guard checks. This
PEP proposes to add a private version to dictionaries to implement fast
guards on namespaces.
Dictionary lookups can be skipped if the version does not change which
Dictionary lookups can be skipped if the version does not change, which
is the common case for most namespaces. The version is globally unique,
so checking the version is also enough to check if the namespace
so checking the version is also enough to verify that the namespace
dictionary was not replaced with a new dictionary.
When the dictionary version does not change, the performance of a guard
@ -49,13 +49,14 @@ complexity is O(1).
Example of optimization: copy the value of a global variable to function
constants. This optimization requires a guard on the global variable to
check if it was modified. If the global variable is not modified, the
function uses the cached copy. If the global variable is modified, the
function uses a regular lookup, and maybe also deoptimize the function
(to remove the overhead of the guard check for next function calls).
check if it was modified after it was copied. If the global variable is
not modified, the function uses the cached copy. If the global variable
is modified, the function uses a regular lookup, and maybe also
deoptimizes the function (to remove the overhead of the guard check for
next function calls).
See the `PEP 510 -- Specialized functions with guards
<https://www.python.org/dev/peps/pep-0510/>`_ for the concrete usage of
<https://www.python.org/dev/peps/pep-0510/>`_ for concrete usage of
guards to specialize functions and for a more general rationale on
Python static optimizers.
@ -63,7 +64,7 @@ Python static optimizers.
Guard example
=============
Pseudo-code of an fast guard to check if a dictionary entry was modified
Pseudo-code of a fast guard to check if a dictionary entry was modified
(created, updated or deleted) using an hypothetical
``dict_get_version(dict)`` function::
@ -211,7 +212,7 @@ Example using an hypothetical ``dict_get_version(dict)`` function::
103
``dict.__setitem__(key, value)`` and ``dict.update(...)`` always
increases the version, even if the new value is identical or is equal to
increase the version, even if the new value is identical or is equal to
the current value (even if ``(dict[key] is value) or (dict[key] ==
value)``).
@ -259,7 +260,7 @@ Integer overflow
The implementation uses the C type ``PY_UINT64_T`` to store the version:
a 64 bits unsigned integer. The C code uses ``version++``. On integer
overflow, the version is wrapped to ``0`` (and then continue to be
overflow, the version is wrapped to ``0`` (and then continues to be
incremented) according to the C standard.
After an integer overflow, a guard can succeed whereas the watched
@ -337,7 +338,7 @@ structure, the field has the C type ``PY_UINT64_T``. When a key is
created or modified, the entry version is set to the dictionary version
which is incremented at any change (create, modify, delete).
Pseudo-code of an fast guard to check if a dictionary key was modified
Pseudo-code of a fast guard to check if a dictionary key was modified
using hypothetical ``dict_get_version(dict)`` and
``dict_get_entry_version(dict)`` functions::