Skip to content

Provide an option to use orjson instead of json #562

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ jobs:
cache: "pip"
cache-dependency-path: setup.py
- name: Install dependencies
if: matrix.python != 'pypy-3.9' && matrix.python != 'pypy-3.10'
run: |
sudo apt-get update
sudo apt-get install libkrb5-dev
pip install wheel
pip install .[tests,gssapi,orjson] sqlalchemy${{ matrix.sqlalchemy }}
- name: Install dependencies in pypy
if: matrix.python == 'pypy-3.9' || matrix.python == 'pypy-3.10'
run: |
sudo apt-get update
sudo apt-get install libkrb5-dev
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# PyPy compatibility issue https://github.com/jborean93/pykrb5/issues/49
"krb5 == 0.5.1"]
sqlalchemy_require = ["sqlalchemy >= 1.3"]
orjson_require = ["orjson >= 3.0.0"]
external_authentication_token_cache_require = ["keyring"]

# We don't add localstorage_require to all_require as users must explicitly opt in to use keyring.
Expand Down Expand Up @@ -96,6 +97,7 @@
"kerberos": kerberos_require,
"gssapi": gssapi_require,
"sqlalchemy": sqlalchemy_require,
"orjson": orjson_require,
"tests": tests_require,
"external-authentication-token-cache": external_authentication_token_cache_require,
},
Expand Down
6 changes: 5 additions & 1 deletion trino/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import base64
import copy
import functools
import json
import os
import random
import re
Expand Down Expand Up @@ -84,6 +83,11 @@
from trino.mapper import RowMapper
from trino.mapper import RowMapperFactory

try:
import orjson as json
except ImportError:
import json

__all__ = [
"ClientSession",
"TrinoQuery",
Expand Down