- 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.
推薦閱讀
- C++面向對象程序設計(第三版)
- Hands-On Machine Learning with scikit:learn and Scientific Python Toolkits
- Julia機器學習核心編程:人人可用的高性能科學計算
- Python高效開發實戰:Django、Tornado、Flask、Twisted(第2版)
- C語言程序設計案例精粹
- Ext JS 4 Web Application Development Cookbook
- Java Web開發就該這樣學
- Rust游戲開發實戰
- UI設計全書(全彩)
- FPGA嵌入式項目開發實戰
- 一覽眾山小:ASP.NET Web開發修行實錄
- Apache Solr for Indexing Data
- C語言程序設計實驗指導
- Manage Your SAP Projects with SAP Activate
- Android項目實戰:博學谷