推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
rogwan
V2EX  ›  Python

pyarmor 加密的 Python 脚本,影响运行效率吗?

  •  
  •   rogwan · Oct 30, 2021 · 3245 views
    This topic created in 1684 days ago, the information mentioned may be changed or developed.
    有用过的朋友,了解这方面的情况:
    1. 加密后,影响运行效率吗?
    2. 保护效力怎么样?
    4 replies    2021-11-09 15:30:29 +08:00
    2i2Re2PLMaDnghL
        1
    2i2Re2PLMaDnghL  
       Oct 30, 2021
    粗略地看了一下。

    是混淆性地编译到字节码,不是加密。
    1. 应当相对明显地影响启动效率,要动态地插入内存。
    2. 与一般编译性语言的混淆类似,属于一般二进制分发保护之范畴。

    有个问题是,有操作系统和运行时的平台依赖,比如向 TempleOS 移植了 CPython ,混淆后的代码必不可用。Pypy ,IronPython 和 Jython 下大概率不可用,除非有专门适配。
    Juszoe
        2
    Juszoe  
       Oct 30, 2021
    借楼问一下大家,我看见 pyarmor 的混淆功能可以将所有.py 文件打包到一个.py 文件里。
    那我不需要混淆功能,只需要将工程打包为单个.py 的功能,请问有没相应的库?
    ClericPy
        3
    ClericPy  
       Oct 30, 2021   ❤️ 1
    @Juszoe 可以试试我之前写的一个 zipapps

    https://github.com/ClericPy/zipapps

    如果不想打包依赖只打包代码, 那它就不会产生缓存, 不过依赖就得自己想办法了比如虚拟环境或者用它打包一个依赖专门的 pyz

    如果想打包依赖, 有些 C 相关的库得保证打包环境和运行环境基本一致.

    如果想惰性打包依赖 (运行的时候安装依赖, 打包时候只记录依赖安装命令), 使用 -d 模式

    目前在 Serverless 和 Hadoop 上用这玩意打包的, 日常需要在一些 docker 里动态下载更新代码也会用到
    vanton
        4
    vanton  
       Nov 9, 2021
    @Juszoe #2
    python -m compileall
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   901 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 61ms · UTC 21:48 · PVG 05:48 · LAX 14:48 · JFK 17:48
    ♥ Do have faith in what you're doing.