我正在加载一个大的 yaml 文件,它需要很长时间。我想知道是否有比 yaml.load() 方法更快的方法。
我读过有一个 CLoader 方法,但无法运行它。
建议此 CLoader 方法的网站要求我这样做:
Download the source package PyYAML-3.08.tar.gz and unpack it.
Go to the directory PyYAML-3.08 and run:
$ python setup.py install
If you want to use LibYAML bindings, which are much faster than the pure Python version, you need to download and install LibYAML.
Then you may build and install the bindings by executing
$ python setup.py --with-libyaml install
In order to use LibYAML based parser and emitter, use the classes CParser and CEmitter:
from yaml import load, dump
try:
from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
from yaml import Loader, Dumper
这看起来可行,但我的 Django 项目中的任何地方都没有 setup.py 目录,因此无法安装/导入任何这些东西
谁能帮我弄清楚如何做到这一点,或者让我知道另一种更快的加载方法?
谢谢您的帮助!!