【问题标题】:Are pyc files independent of the interpreter architecture?pyc 文件是否独立于解释器架构?
【发布时间】:2011-04-18 19:33:41
【问题描述】:

根据我所做的测试,使用相同版本的 python(相同的幻数),64 位解释器可以加载使用 32 位版本的 python 生成的 pyc 文件。反过来,我假设。

但它完全安全吗?这会导致意外行为吗?

【问题讨论】:

  • 你可能会对PEP 3147 -- PYC Repository Directories感兴趣。
  • 谢谢,我看过这个 PEP,但它是针对 python 3.2 的,我更关心 python 的发布版本。尤其是 2.* 分支。

标签: python 64-bit 32-bit pyc


【解决方案1】:

pyc 文件以 python marshal 格式存储。

http://daeken.com/python-marshal-format

似乎唯一的问题是编码整数在 32 位机器上读取 pyc 时会自动降级为 32 位整数。

但是 pyc 格式不包含 64 位地址/偏移量,因此相同的 pyc 应该在 64 位和 32 位解释器上运行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-01
    • 2014-09-20
    • 2011-05-16
    • 2011-12-23
    • 1970-01-01
    相关资源
    最近更新 更多