I am parsing a YAML file with around 6500 lines with this format:
foo1:
bar1:
blah: { name: \"john\", age: 123 }
metadata: { whatever1: \"whatever\", wha
According to the docs you must use CLoader
/CSafeLoader
(and CDumper
):
import yaml
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader
config_file = "test.yaml"
stream = open(config_file, "r")
sensors = yaml.load(stream, Loader=Loader)
This gives me
real 0m0.503s
instead of
real 0m2.714s