Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-74929: PEP 667 general docs update #119201

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

Merged
merged 20 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use US spelling for 'optimized'
  • Loading branch information
ncoghlan committed May 21, 2024
commit e109eeeaf47486be1b3b372e7fc78da5cd785490
4 changes: 2 additions & 2 deletions 4 Doc/c-api/frame.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ See also :ref:`Reflection <reflection>`.
.. c:function:: PyObject* PyFrame_GetLocals(PyFrameObject *frame)

Get the *frame*'s :attr:`~frame.f_locals` attribute.
If the frame refers to an :term:`optimised scope`, this returns a
If the frame refers to an :term:`optimized scope`, this returns a
write-through proxy object that allows modifying the locals.
In all other cases (classes, modules, :func:`exec`, :func:`eval`) it returns
the mapping representing the frame locals directly (as described for
Expand All @@ -132,7 +132,7 @@ See also :ref:`Reflection <reflection>`.
.. versionadded:: 3.11

.. versionchanged:: 3.13
As part of :pep:`667`, return a proxy object for optimised scopes.
As part of :pep:`667`, return a proxy object for optimized scopes.


.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
Expand Down
6 changes: 3 additions & 3 deletions 6 Doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -889,12 +889,12 @@ Glossary
(methods). Also the ultimate base class of any :term:`new-style
class`.

optimised scope
optimized scope
A scope where target local variable names are reliably known to the
compiler when the code is compiled, allowing optimisation of read and
compiler when the code is compiled, allowing optimization of read and
write access to these names. The local namespaces for functions,
generators, coroutines, comprehensions, and generator expressions are
optimised.
optimized in this fashion.

package
A Python :term:`module` which can contain submodules or recursively,
Expand Down
4 changes: 2 additions & 2 deletions 4 Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ are always available. They are listed here in alphabetical order.
deleting local variables will immediately affect the contents of the
returned mapping object.

In an :term:`optimised scope` (including functions, generators, and
In an :term:`optimized scope` (including functions, generators, and
coroutines), each call to ``locals()`` instead returns a fresh dictionary
containing the current bindings of the function's local variables and any
nonlocal cell references. In this case, name binding changes made via the
Expand All @@ -1115,7 +1115,7 @@ are always available. They are listed here in alphabetical order.
.. versionchanged:: 3.13
As part of :pep:`667`, the semantics of mutating the mapping objects
returned from this function are now defined. The behavior in
:term:`optimised scopes <optimised scope>` is now as described above.
:term:`optimized scopes <optimized scope>` is now as described above.
Aside from being defined, the behaviour in other scopes remains
unchanged from previous versions.

Expand Down
4 changes: 2 additions & 2 deletions 4 Doc/library/pdb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ The typical usage to inspect a crashed program is::

.. versionchanged:: 3.13
The implementation of :pep:`667` means that name assignments made via ``pdb``
will consistently and directly affect the active scope, even when running
inside an :term:`optimised scope`.
will immediately affect the active scope, even when running inside an
:term:`optimized scope`.


The module defines the following functions; each enters the debugger in a
Expand Down
2 changes: 1 addition & 1 deletion 2 Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ Special read-only attributes
* - .. attribute:: frame.f_locals
- The dictionary used by the frame to look up
:ref:`local variables <naming>`.
If the frame refers to an :term:`optimised scope`,
If the frame refers to an :term:`optimized scope`,
this may return a write-through proxy object.

.. versionchanged:: 3.13
Expand Down
6 changes: 3 additions & 3 deletions 6 Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ has been left to individual Python implementations to define.

Through :pep:`667`, Python 3.13 standardises the historical behaviour of CPython
for most code execution scopes, but changes
:term:`optimised scopes <optimised scope>` (functions, generators, coroutines,
:term:`optimized scopes <optimized scope>` (functions, generators, coroutines,
comprehensions, and generator expressions) to explicitly return independent
snapshots of the currently assigned local variables, including locally
referenced nonlocal variables captured in closures.
Expand Down Expand Up @@ -2206,7 +2206,7 @@ Changes in the Python API
returned by :meth:`zipfile.ZipFile.open` was changed from ``'r'`` to ``'rb'``.
(Contributed by Serhiy Storchaka in :gh:`115961`.)

* Calling :func:`locals` in an :term:`optimised scope` now produces an
* Calling :func:`locals` in an :term:`optimized scope` now produces an
independent snapshot on each call, and hence no longer implicitly updates
previously returned references. Obtaining the legacy CPython behaviour now
requires explicit calls to update the initially returned dictionary with the
Expand All @@ -2220,7 +2220,7 @@ Changes in the Python API
:pep:`709`. (Changed as part of :pep:`667`.)

ncoghlan marked this conversation as resolved.
Show resolved Hide resolved
* Accessing :attr:`FrameType.f_locals <frame.f_locals>` in an
:term:`optimised scope` now returns a write-through proxy rather than a
:term:`optimized scope` now returns a write-through proxy rather than a
snapshot that gets updated at ill-specified times. If a snapshot is desired,
it must be created explicitly with ``dict`` or the proxy's ``.copy()`` method.
(Changed as part of :pep:`667`.)
Expand Down
2 changes: 1 addition & 1 deletion 2 Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def setup(self, f, tb):
# locals whenever the .f_locals accessor was called, so it was
# cached here to ensure that modifications were not overwritten. While
# the caching is no longer required now that f_locals is a direct proxy
# on optimised frames, it's also harmless, so the code structure has
# on optimized frames, it's also harmless, so the code structure has
# been left unchanged.
self.curframe_locals = self.curframe.f_locals
self.set_convenience_variable(self.curframe, '_frame', self.curframe)
Expand Down
2 changes: 1 addition & 1 deletion 2 Lib/test/test_gdb/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def get_stack_trace(self, source=None, script=None,
print(line, file=sys.stderr)

# bpo-34007: Sometimes some versions of the shared libraries that
# are part of the traceback are compiled in optimised mode and the
# are part of the traceback are compiled in optimized mode and the
# Program Counter (PC) is not present, not allowing gdb to walk the
# frames back. When this happens, the Python bindings of gdb raise
# an exception, making the test impossible to succeed.
Expand Down
2 changes: 1 addition & 1 deletion 2 Misc/HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -15056,7 +15056,7 @@ Tests
-----

- Issue #5354: New test support function import_fresh_module() makes
it easy to import both normal and optimised versions of modules.
it easy to import both normal and optimized versions of modules.
test_heapq and test_warnings have been adjusted to use it, tests for
other modules with both C and Python implementations in the stdlib
can be adjusted to use it over time.
Expand Down
2 changes: 1 addition & 1 deletion 2 Misc/NEWS.d/3.11.0a1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ singleton is destroyed by mistake. Patch by Victor Stinner.
.. nonce: ZFgFSj
.. section: Core and Builtins

sum() was further optimised for summing up single digit integers.
sum() was further optimized for summing up single digit integers.

..

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.