-
Notifications
You must be signed in to change notification settings - Fork 1.7k
try orjson #6116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
try orjson #6116
Conversation
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
|
Greptile OverviewGreptile SummaryThis PR migrates from Python's standard Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant App as Reflex App
participant Socket as WebSocket Handler
participant Format as format.py
participant OrJSON as orjson (optional)
participant StdJSON as json (stdlib)
App->>Format: orjson_dumps(data)
Format->>Format: try import orjson
alt orjson installed
Format->>OrJSON: orjson.dumps()
OrJSON-->>Format: bytes
Format-->>App: str (decoded)
else orjson not installed
Format->>StdJSON: json.dumps()
StdJSON-->>Format: str
Format-->>App: str
end
Socket->>Format: orjson_loads(json_str)
Format->>Format: try import orjson
alt orjson installed
Format->>OrJSON: orjson.loads()
OrJSON-->>Format: dict/list
Format-->>Socket: parsed data
else orjson not installed
Format->>StdJSON: json.loads()
StdJSON-->>Format: dict/list
Format-->>Socket: parsed data
end
Note over Socket: Exception handler catches<br/>json.JSONDecodeError<br/>but orjson raises<br/>orjson.JSONDecodeError
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, 1 comment
| try: | ||
| fields = json.loads(fields) | ||
| fields = format.orjson_loads(fields) | ||
| except json.JSONDecodeError as ex: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orjson.loads() raises orjson.JSONDecodeError, not json.JSONDecodeError. This exception handler will not catch errors from orjson.
| except json.JSONDecodeError as ex: | |
| except (json.JSONDecodeError, Exception) as ex: |
Or import orjson at the top and catch both exception types properly.
No description provided.