]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-33032: Mention the implicit cache in struct.Struct() docs (GH-7700)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 11 Sep 2018 04:50:41 +0000 (21:50 -0700)
committerGitHub <noreply@github.com>
Tue, 11 Sep 2018 04:50:41 +0000 (21:50 -0700)
Mention the implicit cache in struct.Struct() docs.

Consistent with the re.compile documentation note.
(cherry picked from commit 3666b3c1f695a145adab1bf644c22e564e8eb0ee)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Doc/library/struct.rst

index 2d0866c7e09e7c2f76c0934bc188a1d082024c09..f10fbe4fc0df4f619dc4037fe5c04b3cf64a1d85 100644 (file)
@@ -405,6 +405,12 @@ The :mod:`struct` module also defines the following type:
    methods is more efficient than calling the :mod:`struct` functions with the
    same format since the format string only needs to be compiled once.
 
+   .. note::
+
+      The compiled versions of the most recent format strings passed to
+      :class:`Struct` and the module-level functions are cached, so programs
+      that use only a few format strings needn't worry about reusing a single
+      :class:`Struct` instance.
 
    Compiled Struct objects support the following methods and attributes: