简体   繁体   English

Python:是否可以修补2.X,以便完全忽略* .pyc文件?

[英]Python: can 2.X be patched so as to totally ignore *.pyc files?

executive summary: python lib on NFS, duelling pythons 2.6 and 2.7. 执行摘要:NFS上的python lib,对应pythons 2.6和2.7。

context: several groups maintain their own python interpreters, but access common python libraries on an NFS server. 上下文:几个组维护自己的python解释器,但访问NFS服务器上的通用python库。

Is there an easy way to build python so that it ignores pyc files? 有没有一种简单的方法来构建python,使其忽略pyc文件? It's not practical to try and ensure that every script is executed with a -B option. 尝试确保每个脚本都使用-B选项执行是不切实际的。

It seems to be the actual statting to see if the files exist that is causing the NFS load. 似乎实际情况是查看文件是否存在导致NFS加载。

If the oldest python being run is at least 2.6, no patching is necessary. 如果运行的最旧的python至少为2.6,则无需修补。

Add

import sys
sys.dont_write_bytecode = True

to

site-packages/usercustomize.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM