Why compile Python code?

后端 未结 10 1851
时光取名叫无心
时光取名叫无心 2020-11-27 09:37

Why would you compile a Python script? You can run them directly from the .py file and it works fine, so is there a performance advantage or something?

I also notic

10条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 10:05

    As already mentioned, you can get a performance increase from having your python code compiled into bytecode. This is usually handled by python itself, for imported scripts only.

    Another reason you might want to compile your python code, could be to protect your intellectual property from being copied and/or modified.

    You can read more about this in the Python documentation.

提交回复
热议问题