File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,30 @@ can use an opt-in or opt-out approach by setting its value:
3939* targets must opt-out: ` --@rules_python//python/config_settings:precompile=enabled `
4040* targets must opt-in: ` --@rules_python//python/config_settings:precompile=disabled `
4141
42+ ## Pyc-only builds
43+
44+ A pyc-only build (aka "source less" builds) is when only ` .pyc ` files are
45+ included; the source ` .py ` files are not included.
46+
47+ To enable this, set
48+ {obj}` --@rules_python//python/config_settings:precompile_source_retention=omit_source `
49+ flag on the command line or the {attr}` precompile_source_retention=omit_source `
50+ attribute on specific targets.
51+
52+ The advantage of pyc-only builds are:
53+ * Fewer total files in a binary.
54+ * Imports _ may_ be _ slightly_ faster.
55+
56+ The disadvantages are:
57+ * Error messages will be less precise because the precise line and offset
58+ information isn't in an pyc file.
59+ * pyc files are Python major-version specific.
60+
61+ :::{note}
62+ pyc files are not a form of hiding source code. They are trivial to uncompile,
63+ and uncompiling them can recover almost the original source.
64+ :::
65+
4266## Advanced precompiler customization
4367
4468The default implementation of the precompiler is a persistent, multiplexed,
You can’t perform that action at this time.
0 commit comments