Skip to content

Commit 5cde93b

Browse files
committed
pyc -> .pyc files
1 parent a243350 commit 5cde93b

File tree

6 files changed

+60
-54
lines changed

6 files changed

+60
-54
lines changed

Doc/library/compileall.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ compile Python sources.
8686
.. cmdoption:: --invalidation-mode [timestamp|checked-hash|unchecked-hash]
8787

8888
Control how the generated pycs will be invalidated at runtime. The default
89-
setting, ``timestamp``, means that pyc files with the source timestamp and
90-
size embedded will be generated. The ``checked-hash`` and ``unchecked-hash``
91-
values cause hash-based pycs to be generated. Hash-based pycs embed a hash of
92-
the source file contents rather than a timestamp. See :ref:`pyc-invalidation`
93-
for more information on how Python validates bytecode cache files at runtime.
89+
setting, ``timestamp``, means that ``.pyc`` files with the source timestamp
90+
and size embedded will be generated. The ``checked-hash`` and
91+
``unchecked-hash`` values cause hash-based pycs to be generated. Hash-based
92+
pycs embed a hash of the source file contents rather than a timestamp. See
93+
:ref:`pyc-invalidation` for more information on how Python validates bytecode
94+
cache files at runtime.
9495

9596
.. versionchanged:: 3.2
9697
Added the ``-i``, ``-b`` and ``-h`` options.

Doc/library/importlib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,8 +1332,8 @@ an :term:`importer`.
13321332

13331333
.. function:: source_hash(source_bytes)
13341334

1335-
Return the hash of *source_bytes* as byte string. A hash-based pyc embeds the
1336-
:func:`source_hash` of the corresponding source file's contents in its
1335+
Return the hash of *source_bytes* as bytes. A hash-based ``.pyc`` file embeds
1336+
the :func:`source_hash` of the corresponding source file's contents in its
13371337
header.
13381338

13391339
.. versionadded:: 3.7

Doc/library/py_compile.rst

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ byte-code cache files in the directory containing the source code.
5454
level of the current interpreter.
5555

5656
*invalidation_mode* should be a member of the :class:`PycInvalidationMode`
57-
enum and controls how the generated pycs are invalidated at runtime.
57+
enum and controls how the generated ``.pyc`` files are invalidated at
58+
runtime.
5859

5960
.. versionchanged:: 3.2
6061
Changed default value of *cfile* to be :PEP:`3147`-compliant. Previous
@@ -75,32 +76,33 @@ byte-code cache files in the directory containing the source code.
7576
.. class:: PycInvalidationMode
7677

7778
A enumeration of possible methods the interpreter can use to determine
78-
whether a bytecode file is up to date with a source file. The pyc indicates
79-
the desired invalidation mode in its header. See :ref:`pyc-invalidation` for
80-
more information on how Python invalidates pycs at runtime.
79+
whether a bytecode file is up to date with a source file. The ``.pyc`` file
80+
indicates the desired invalidation mode in its header. See
81+
:ref:`pyc-invalidation` for more information on how Python invalidates
82+
``.pyc`` files at runtime.
8183

8284
.. versionadded:: 3.7
8385

8486
.. attribute:: TIMESTAMP
8587

86-
The pyc includes the timestamp and size of the source file, which Python
87-
will compare against the metadata of the source file at runtime to
88-
determine if the pyc needs to be regenerated.
88+
The ``.pyc`` file includes the timestamp and size of the source file,
89+
which Python will compare against the metadata of the source file at
90+
runtime to determine if the ``.pyc`` file needs to be regenerated.
8991

9092
.. attribute:: CHECKED_HASH
9193

92-
The pyc includes a hash of the source file content, which Python will
93-
compare against the source at runtime to determine if the pyc needs to be
94-
regenerated.
94+
The ``.pyc`` file includes a hash of the source file content, which Python
95+
will compare against the source at runtime to determine if the ``.pyc``
96+
file needs to be regenerated.
9597

9698
.. attribute:: UNCHECKED_HASH
9799

98-
Like :attr:`CHECKED_HASH`, the pyc includes a hash of the source file
99-
content. However, Python will at runtime assume the pyc is up to date and
100-
not validate the pyc against the source file at all.
100+
Like :attr:`CHECKED_HASH`, the ``.pyc`` file includes a hash of the source
101+
file content. However, Python will at runtime assume the ``.pyc`` file is
102+
up to date and not validate the ``.pyc`` against the source file at all.
101103

102-
This option is useful when the pycs are kept up to date by some system
103-
external to Python like a build system.
104+
This option is useful when the ``.pycs`` are kept up to date by some
105+
system external to Python like a build system.
104106

105107

106108
.. function:: main(args=None)

Doc/reference/import.rst

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -689,17 +689,18 @@ metadata.
689689

690690
Python also supports "hash-based" cache files, which store a hash of a source
691691
file contents rather than its metadata. There are two variants of hash-based
692-
pycs: checked and unchecked. For checked hash-based pycs, Python validates the
693-
cache file by hashing the source file and comparing the resulting hash with the
694-
hash in the cache file. If a checked hash-based cache file is found to be
695-
invalid, Python regenerates it and writes a new checked hash-based cache
696-
file. For unchecked hash-based pycs, Python simply assumes the cache file is
697-
valid if it exists. Hash-based pyc validation behavior may be override with the
698-
:option:`--check-hash-based-pycs` flag.
692+
``.pyc`` files: checked and unchecked. For checked hash-based ``.pyc`` files,
693+
Python validates the cache file by hashing the source file and comparing the
694+
resulting hash with the hash in the cache file. If a checked hash-based cache
695+
file is found to be invalid, Python regenerates it and writes a new checked
696+
hash-based cache file. For unchecked hash-based ``.pyc`` files, Python simply
697+
assumes the cache file is valid if it exists. Hash-based ``.pyc`` files
698+
validation behavior may be override with the :option:`--check-hash-based-pycs`
699+
flag.
699700

700701
.. versionchanged:: 3.7
701-
Added hash-based pycs. Previously, Python only supported timestamp-based pyc
702-
invalidation.
702+
Added hash-based ``.pyc`` files. Previously, Python only supported
703+
timestamp-based invalidation of bytecode caches.
703704

704705

705706
The Path Based Finder

Doc/using/cmdline.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,16 @@ Miscellaneous options
212212

213213
.. cmdoption:: --check-hash-based-pycs default|always|never
214214

215-
Control the validation behavior of hash-based pycs. See
215+
Control the validation behavior of hash-based ``.pyc`` files. See
216216
:ref:`pyc-invalidation`. When set to ``default``, checked and unchecked
217217
hash-based bytecode cache files are validated according to their default
218-
semantics. When set to ``always``, all hash-based pycs, whether checked or
219-
unchecked, are validated against their corresponding source file. When set to
220-
``never``, hash-based pycs are not validated against their corresponding
221-
source files.
218+
semantics. When set to ``always``, all hash-based ``.pyc`` files, whether
219+
checked or unchecked, are validated against their corresponding source
220+
file. When set to ``never``, hash-based ``.pyc`` files are not validated
221+
against their corresponding source files.
222222

223-
The semantics of timestamp-based pycs are unaffected by this option.
223+
The semantics of timestamp-based ``.pyc`` files are unaffected by this
224+
option.
224225

225226

226227
.. cmdoption:: -d

Doc/whatsnew/3.7.rst

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -201,25 +201,26 @@ Hash-based pycs
201201
---------------
202202

203203
Python has traditionally checked the up-to-dateness of bytecode cache files
204-
(i.e., pycs) by comparing the source metadata (last-modified timestamp and size)
205-
with source metadata saved in the cache file header when it was generated. While
206-
effective, this invalidation method has its drawbacks. When filesystem
207-
timestamps are too coarse, Python can miss source updates, leading to user
208-
confusion. Additionally, having a timestamp in the cache file is problematic for
209-
`build reproduciblity <https://reproducible-builds.org/>`_ and content-based
210-
build systems.
204+
(i.e., ``.pyc`` files) by comparing the source metadata (last-modified timestamp
205+
and size) with source metadata saved in the cache file header when it was
206+
generated. While effective, this invalidation method has its drawbacks. When
207+
filesystem timestamps are too coarse, Python can miss source updates, leading to
208+
user confusion. Additionally, having a timestamp in the cache file is
209+
problematic for `build reproduciblity <https://reproducible-builds.org/>`_ and
210+
content-based build systems.
211211

212212
:pep:`552` extends the pyc format to allow the hash of the source file to be
213-
used for invalidation instead of the source timestamp. Such pycs are called
214-
"hash-based". By default, Python still uses timestamp-based invalidation and
215-
does not generate hash-based pycs at runtime. Hash-based pycs may be generated
216-
with :mod:`py_compile` or :mod:`compileall`.
217-
218-
Hash-based pycs come in two variants: checked and unchecked. Python validates
219-
checked hash-based pycs against the source file at runtime but doesn't do so for
220-
unchecked hash-based pycs. Unchecked hash-based pycs are a useful performance
221-
optimization for environments where a system external to Python (e.g., the build
222-
system) is responsible for keeping pycs up-to-date.
213+
used for invalidation instead of the source timestamp. Such ``.pyc`` files are
214+
called "hash-based". By default, Python still uses timestamp-based invalidation
215+
and does not generate hash-based ``.pyc`` files at runtime. Hash-based ``.pyc``
216+
files may be generated with :mod:`py_compile` or :mod:`compileall`.
217+
218+
Hash-based ``.pyc`` files come in two variants: checked and unchecked. Python
219+
validates checked hash-based ``.pyc`` files against the corresponding source
220+
files at runtime but doesn't do so for unchecked hash-based pycs. Unchecked
221+
hash-based ``.pyc`` files are a useful performance optimization for environments
222+
where a system external to Python (e.g., the build system) is responsible for
223+
keeping ``.pyc`` files up-to-date.
223224

224225
See :ref:`pyc-invalidation` for more information.
225226

0 commit comments

Comments
 (0)