Problem: Rapid JSON is outdated and slow

Solution: Use the last version of Rapid JSON.
This commit is contained in:
vrde 2018-08-17 12:40:22 +02:00
parent abdd23f5a6
commit 46d09de458
No known key found for this signature in database
GPG Key ID: 6581C7C39B3D397D
2 changed files with 3 additions and 5 deletions

View File

@ -9,7 +9,6 @@ import logging
import jsonschema import jsonschema
import yaml import yaml
import rapidjson import rapidjson
import rapidjson_schema
from bigchaindb.common.exceptions import SchemaValidationError from bigchaindb.common.exceptions import SchemaValidationError
@ -22,7 +21,7 @@ def _load_schema(name, path=__file__):
path = os.path.join(os.path.dirname(path), name + '.yaml') path = os.path.join(os.path.dirname(path), name + '.yaml')
with open(path) as handle: with open(path) as handle:
schema = yaml.safe_load(handle) schema = yaml.safe_load(handle)
fast_schema = rapidjson_schema.loads(rapidjson.dumps(schema)) fast_schema = rapidjson.Validator(rapidjson.dumps(schema))
return path, (schema, fast_schema) return path, (schema, fast_schema)
@ -57,7 +56,7 @@ def _validate_schema(schema, body):
# a helpful error message. # a helpful error message.
try: try:
schema[1].validate(rapidjson.dumps(body)) schema[1](rapidjson.dumps(body))
except ValueError as exc: except ValueError as exc:
try: try:
jsonschema.validate(body, schema[0]) jsonschema.validate(body, schema[0])

View File

@ -80,7 +80,7 @@ install_requires = [
'pymongo~=3.6', 'pymongo~=3.6',
'pysha3~=1.0.2', 'pysha3~=1.0.2',
'cryptoconditions~=0.6.0.dev', 'cryptoconditions~=0.6.0.dev',
'python-rapidjson==0.0.11', 'python-rapidjson~=0.6.0',
'logstats~=0.2.1', 'logstats~=0.2.1',
'flask>=0.10.1', 'flask>=0.10.1',
'flask-cors~=3.0.0', 'flask-cors~=3.0.0',
@ -90,7 +90,6 @@ install_requires = [
'jsonschema~=2.5.1', 'jsonschema~=2.5.1',
'pyyaml~=3.12', 'pyyaml~=3.12',
'aiohttp~=3.0', 'aiohttp~=3.0',
'python-rapidjson-schema==0.1.1',
'bigchaindb-abci==0.5.1', 'bigchaindb-abci==0.5.1',
'setproctitle~=1.1.0', 'setproctitle~=1.1.0',
] ]