- 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.
推薦閱讀
- 軟件安全技術(shù)
- PWA入門與實(shí)踐
- 測試驅(qū)動開發(fā):入門、實(shí)戰(zhàn)與進(jìn)階
- Vue.js快跑:構(gòu)建觸手可及的高性能Web應(yīng)用
- 深入淺出Spring Boot 2.x
- 區(qū)塊鏈架構(gòu)與實(shí)現(xiàn):Cosmos詳解
- Expert Android Programming
- 零基礎(chǔ)入門學(xué)習(xí)Python
- 名師講壇:Spring實(shí)戰(zhàn)開發(fā)(Redis+SpringDataJPA+SpringMVC+SpringSecurity)
- SSM開發(fā)實(shí)戰(zhàn)教程(Spring+Spring MVC+MyBatis)
- 持續(xù)集成與持續(xù)交付實(shí)戰(zhàn):用Jenkins、Travis CI和CircleCI構(gòu)建和發(fā)布大規(guī)模高質(zhì)量軟件
- Nagios Core Administration Cookbook(Second Edition)
- Mockito Essentials
- Learning Ionic
- 超好玩的Scratch 3.5少兒編程