- Secret Recipes of the Python Ninja
- Cody Jackson
- 155字
- 2021-06-25 22:14:43
How to do it...
- To create bytecode, simply execute a Python program via python <program>.py.
- When running a Python command from the command line, there are a couple of switches that can reduce the size of the compiled bytecode. Be aware that some programs may expect the statements that are removed from the following examples to function correctly, so only use them if you know what to expect.
-O removes assert statements from the compiled code. These statements provide some debugging help when testing the program, but generally aren't required for production code.
-OO removes both assert and __doc__ strings for even more size reduction.
- Loading programs from bytecode into memory is faster than with source code, but actual program execution is no faster (due to the nature of the Python interpreter).
- The compileall module can generate bytecode for all modules within a directory. More information on the command can be found at https://docs.python.org/3.6/library/compileall.html.
推薦閱讀
- 數據庫系統原理及MySQL應用教程(第2版)
- Microsoft Exchange Server PowerShell Cookbook(Third Edition)
- 跟“龍哥”學C語言編程
- 高級C/C++編譯技術(典藏版)
- Mastering Predictive Analytics with Python
- Building Serverless Applications with Python
- 微信小程序全棧開發技術與實戰(微課版)
- Clojure for Java Developers
- Python預測之美:數據分析與算法實戰(雙色)
- C# 7.1 and .NET Core 2.0:Modern Cross-Platform Development(Third Edition)
- Spring Web Services 2 Cookbook
- HTML5 Canvas核心技術:圖形、動畫與游戲開發
- 軟件開發中的決策:權衡與取舍
- PhantomJS Cookbook
- Build Your Own PaaS with Docker