summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-03-17 11:13:34 +0200
committerLars Wirzenius <liw@liw.fi>2018-03-17 11:40:02 +0200
commite92515e92689e1a9b7950f936758b191bc61c33a (patch)
treec7edb159ba5a655405cc9c63a0ce16bc523f3a2b
parentc964fa3e4312b83cd20b6d47fabcee290a1ab1c7 (diff)
downloadextrautils-e92515e92689e1a9b7950f936758b191bc61c33a.tar.gz
Change: load using CSafeLoader, for speed
With a 9 MiB input file with 10,000 dicts, SafeLoader loads it in about 10 seconds on my laptop, CSafeLoader in about 0.5 seconds. That's a 20x speed improvement with a one-character change.
-rwxr-xr-xprettyml2
1 files changed, 1 insertions, 1 deletions
diff --git a/prettyml b/prettyml
index fac3ebb..12f1a8e 100755
--- a/prettyml
+++ b/prettyml
@@ -15,5 +15,5 @@ def inputs(args):
objs = []
for filename, f in inputs(sys.argv[1:]):
- objs.append(yaml.safe_load(f))
+ objs.append(yaml.load(f, Loader=yaml.CSafeLoader))
yaml.safe_dump_all(objs, stream=sys.stdout, indent=4, default_flow_style=False)