From f319fedf7e8f57c72393cc5c7b7b02a75aaf3279 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Tue, 6 Jan 2026 17:41:13 +0800 Subject: [PATCH] Update deploy.md --- docs/features/deploy.md | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/features/deploy.md b/docs/features/deploy.md index eac07897..4a629180 100644 --- a/docs/features/deploy.md +++ b/docs/features/deploy.md @@ -8,7 +8,8 @@ order: 81 The feature requires pocketpy version >= `2.1.7` !!! -You can deploy your pocketpy program as bytecode files, which slightly improves the loading speed of your program. +You can deploy your pocketpy program as `.pyc` files, which are compiled bytecodes with necessary metadata. +This slightly improves the loading speed of your program. It also makes your users unable to get your source code directly, unless they do expensive reverse engineering. @@ -29,4 +30,24 @@ It compiles all `.py` files in the specified directory into `.pyc` files. ```sh python compileall.py ./main input_path output_path -``` \ No newline at end of file +``` + +## Running `.pyc` files + +The command-line executable `main` can run `.pyc` files directly: + +```sh +./main output_file.pyc +``` + +If you are using C-APIs, you can use the `py_execo()` function. + +```c +/// Run a compiled code object. +PK_API bool py_execo(const void* data, int size, const char* filename, py_Ref module) PY_RAISE PY_RETURN; +``` + +## Trackback Support + +Since `.pyc` files do not contain raw sources, +trackbacks will show line numbers but not the actual source code lines.