changeset 55:20b76a3c3211 draft

Improve JSON performance by ~2x by making dict parser more clever
author Lewin Bormann <lbo@spheniscida.de>
date Fri, 24 May 2019 00:11:18 +0200
parents 79b3b77fd4bf
children 571cbdc11361
files pcombinators/json_test.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pcombinators/json_test.py	Fri May 24 00:07:58 2019 +0200
+++ b/pcombinators/json_test.py	Fri May 24 00:11:18 2019 +0200
@@ -62,10 +62,10 @@
 # The two-element list is converted to a tuple.
 entry = JString + separator + (Value()) >> (lambda l: tuple(l))
 # A mid entry is followed by a comma.
-midentry = Last(entry + Skip(String(',')))
+midentry = Last(entry + Skip(String(',') | Nothing()))
 # A dict is a {, followed by entries, followed by a final entry, followed by a closing }
 dct = Flatten(
-        Skip(String("{")) + ((Repeat(midentry, -1) + entry)) + Skip(String("}")))
+        Skip(String("{")) + Repeat(midentry, -1) + Skip(String("}")))
 # Convert the list of tuples into a dict.
 Dict = dct >> dict