Skip to content

Commit

Permalink
Revert "Use orjson to parse json faster (home-assistant#32153)" (home…
Browse files Browse the repository at this point in the history
…-assistant#32185)

This reverts commit 2365e2e.
  • Loading branch information
balloob authored Feb 25, 2020
1 parent ceb3985 commit 7d8da47
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 14 deletions.
5 changes: 2 additions & 3 deletions homeassistant/components/recorder/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import json
import logging

import orjson
from sqlalchemy import (
Boolean,
Column,
Expand Down Expand Up @@ -64,7 +63,7 @@ def to_native(self):
try:
return Event(
self.event_type,
orjson.loads(self.event_data),
json.loads(self.event_data),
EventOrigin(self.origin),
_process_timestamp(self.time_fired),
context=context,
Expand Down Expand Up @@ -134,7 +133,7 @@ def to_native(self):
return State(
self.entity_id,
self.state,
orjson.loads(self.attributes),
json.loads(self.attributes),
_process_timestamp(self.last_changed),
_process_timestamp(self.last_updated),
context=context,
Expand Down
2 changes: 0 additions & 2 deletions homeassistant/helpers/aiohttp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from aiohttp.hdrs import CONTENT_TYPE, USER_AGENT
from aiohttp.web_exceptions import HTTPBadGateway, HTTPGatewayTimeout
import async_timeout
import orjson

from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE, __version__
from homeassistant.core import Event, callback
Expand Down Expand Up @@ -68,7 +67,6 @@ def async_create_clientsession(
loop=hass.loop,
connector=connector,
headers={USER_AGENT: SERVER_SOFTWARE},
json_serialize=lambda x: orjson.dumps(x).decode(),
**kwargs,
)

Expand Down
1 change: 0 additions & 1 deletion homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ home-assistant-frontend==20200220.1
importlib-metadata==1.5.0
jinja2>=2.10.3
netdisco==2.6.0
orjson==2.5.1
pip>=8.0.3
python-slugify==4.0.0
pytz>=2019.03
Expand Down
8 changes: 3 additions & 5 deletions homeassistant/util/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import tempfile
from typing import Any, Dict, List, Optional, Type, Union

import orjson

from homeassistant.exceptions import HomeAssistantError

_LOGGER = logging.getLogger(__name__)
Expand All @@ -30,7 +28,7 @@ def load_json(
"""
try:
with open(filename, encoding="utf-8") as fdesc:
return orjson.loads(fdesc.read()) # type: ignore
return json.loads(fdesc.read()) # type: ignore
except FileNotFoundError:
# This is not a fatal error
_LOGGER.debug("JSON file not found: %s", filename)
Expand Down Expand Up @@ -99,7 +97,7 @@ def find_paths_unserializable_data(bad_data: Any) -> List[str]:
obj, obj_path = to_process.popleft()

try:
orjson.dumps(obj)
json.dumps(obj)
continue
except TypeError:
pass
Expand All @@ -108,7 +106,7 @@ def find_paths_unserializable_data(bad_data: Any) -> List[str]:
for key, value in obj.items():
try:
# Is key valid?
orjson.dumps({key: None})
json.dumps({key: None})
except TypeError:
invalid.append(f"{obj_path}<key: {key}>")
else:
Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ignore=tests
jobs=2
load-plugins=pylint_strict_informational
persistent=no
extension-pkg-whitelist=ciso8601,orjson
extension-pkg-whitelist=ciso8601

[BASIC]
good-names=id,i,j,k,ex,Run,_,fp
Expand Down
1 change: 0 additions & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ importlib-metadata==1.5.0
jinja2>=2.10.3
PyJWT==1.7.1
cryptography==2.8
orjson==2.5.1
pip>=8.0.3
python-slugify==4.0.0
pytz>=2019.03
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"PyJWT==1.7.1",
# PyJWT has loose dependency. We want the latest one.
"cryptography==2.8",
"orjson==2.5.1",
"pip>=8.0.3",
"python-slugify==4.0.0",
"pytz>=2019.03",
Expand Down

0 comments on commit 7d8da47

Please sign in to comment.