##// END OF EJS Templates
deps: replaced simplejson with much faster orjson implementation
super-admin -
r4972:da637531 default
parent child Browse files
Show More
@@ -1,266 +1,265 b''
1 # deps, generated via pipdeptree --exclude setuptools,wheel,pipdeptree,pip -f | tr '[:upper:]' '[:lower:]'
1 # deps, generated via pipdeptree --exclude setuptools,wheel,pipdeptree,pip -f | tr '[:upper:]' '[:lower:]'
2
2
3 alembic==1.10.2
3 alembic==1.10.2
4 mako==1.2.4
4 mako==1.2.4
5 markupsafe==2.1.2
5 markupsafe==2.1.2
6 sqlalchemy==1.4.46
6 sqlalchemy==1.4.46
7 greenlet==2.0.2
7 greenlet==2.0.2
8 typing_extensions==4.5.0
8 typing_extensions==4.5.0
9 typing_extensions==4.5.0
9 typing_extensions==4.5.0
10 babel==2.12.1
10 babel==2.12.1
11 celery==5.2.7
11 celery==5.2.7
12 billiard==3.6.4.0
12 billiard==3.6.4.0
13 click==8.1.3
13 click==8.1.3
14 click-didyoumean==0.3.0
14 click-didyoumean==0.3.0
15 click==8.1.3
15 click==8.1.3
16 click-plugins==1.1.1
16 click-plugins==1.1.1
17 click==8.1.3
17 click==8.1.3
18 click-repl==0.2.0
18 click-repl==0.2.0
19 click==8.1.3
19 click==8.1.3
20 prompt-toolkit==3.0.38
20 prompt-toolkit==3.0.38
21 wcwidth==0.2.6
21 wcwidth==0.2.6
22 six==1.16.0
22 six==1.16.0
23 kombu==5.2.4
23 kombu==5.2.4
24 amqp==5.1.1
24 amqp==5.1.1
25 vine==5.0.0
25 vine==5.0.0
26 vine==5.0.0
26 vine==5.0.0
27 pytz==2022.7.1
27 pytz==2022.7.1
28 vine==5.0.0
28 vine==5.0.0
29 channelstream==0.7.1
29 channelstream==0.7.1
30 gevent==22.10.2
30 gevent==22.10.2
31 greenlet==2.0.2
31 greenlet==2.0.2
32 zope.event==4.6
32 zope.event==4.6
33 zope.interface==5.5.2
33 zope.interface==5.5.2
34 itsdangerous==1.1.0
34 itsdangerous==1.1.0
35 marshmallow==2.18.0
35 marshmallow==2.18.0
36 pyramid==2.0.1
36 pyramid==2.0.1
37 hupper==1.11
37 hupper==1.11
38 plaster==1.1.2
38 plaster==1.1.2
39 plaster-pastedeploy==1.0.1
39 plaster-pastedeploy==1.0.1
40 pastedeploy==3.0.1
40 pastedeploy==3.0.1
41 plaster==1.1.2
41 plaster==1.1.2
42 translationstring==1.4
42 translationstring==1.4
43 venusian==3.0.0
43 venusian==3.0.0
44 webob==1.8.7
44 webob==1.8.7
45 zope.deprecation==4.4.0
45 zope.deprecation==4.4.0
46 zope.interface==5.5.2
46 zope.interface==5.5.2
47 pyramid-apispec==0.3.3
47 pyramid-apispec==0.3.3
48 apispec==1.3.3
48 apispec==1.3.3
49 pyramid-jinja2==2.10
49 pyramid-jinja2==2.10
50 jinja2==3.1.2
50 jinja2==3.1.2
51 markupsafe==2.1.2
51 markupsafe==2.1.2
52 markupsafe==2.1.2
52 markupsafe==2.1.2
53 pyramid==2.0.1
53 pyramid==2.0.1
54 hupper==1.11
54 hupper==1.11
55 plaster==1.1.2
55 plaster==1.1.2
56 plaster-pastedeploy==1.0.1
56 plaster-pastedeploy==1.0.1
57 pastedeploy==3.0.1
57 pastedeploy==3.0.1
58 plaster==1.1.2
58 plaster==1.1.2
59 translationstring==1.4
59 translationstring==1.4
60 venusian==3.0.0
60 venusian==3.0.0
61 webob==1.8.7
61 webob==1.8.7
62 zope.deprecation==4.4.0
62 zope.deprecation==4.4.0
63 zope.interface==5.5.2
63 zope.interface==5.5.2
64 zope.deprecation==4.4.0
64 zope.deprecation==4.4.0
65 python-dateutil==2.8.2
65 python-dateutil==2.8.2
66 six==1.16.0
66 six==1.16.0
67 requests==2.28.2
67 requests==2.28.2
68 certifi==2022.12.7
68 certifi==2022.12.7
69 charset-normalizer==3.1.0
69 charset-normalizer==3.1.0
70 idna==3.4
70 idna==3.4
71 urllib3==1.26.14
71 urllib3==1.26.14
72 ws4py==0.5.1
72 ws4py==0.5.1
73 deform==2.0.15
73 deform==2.0.15
74 chameleon==3.10.2
74 chameleon==3.10.2
75 colander==2.0
75 colander==2.0
76 iso8601==1.1.0
76 iso8601==1.1.0
77 translationstring==1.4
77 translationstring==1.4
78 iso8601==1.1.0
78 iso8601==1.1.0
79 peppercorn==0.6
79 peppercorn==0.6
80 translationstring==1.4
80 translationstring==1.4
81 zope.deprecation==4.4.0
81 zope.deprecation==4.4.0
82 docutils==0.19
82 docutils==0.19
83 dogpile.cache==1.1.8
83 dogpile.cache==1.1.8
84 decorator==5.1.1
84 decorator==5.1.1
85 stevedore==5.0.0
85 stevedore==5.0.0
86 pbr==5.11.1
86 pbr==5.11.1
87 formencode==2.0.1
87 formencode==2.0.1
88 six==1.16.0
88 six==1.16.0
89 gunicorn==20.1.0
89 gunicorn==20.1.0
90 infrae.cache==1.0.1
90 infrae.cache==1.0.1
91 beaker==1.12.1
91 beaker==1.12.1
92 repoze.lru==0.7
92 repoze.lru==0.7
93 msgpack-python==0.5.6
93 msgpack-python==0.5.6
94 mysqlclient==2.1.1
94 mysqlclient==2.1.1
95 nbconvert==7.2.9
95 nbconvert==7.2.9
96 beautifulsoup4==4.11.2
96 beautifulsoup4==4.11.2
97 soupsieve==2.4
97 soupsieve==2.4
98 bleach==6.0.0
98 bleach==6.0.0
99 six==1.16.0
99 six==1.16.0
100 webencodings==0.5.1
100 webencodings==0.5.1
101 defusedxml==0.7.1
101 defusedxml==0.7.1
102 jinja2==3.1.2
102 jinja2==3.1.2
103 markupsafe==2.1.2
103 markupsafe==2.1.2
104 jupyter_core==5.2.0
104 jupyter_core==5.2.0
105 platformdirs==3.1.0
105 platformdirs==3.1.0
106 traitlets==5.9.0
106 traitlets==5.9.0
107 jupyterlab-pygments==0.2.2
107 jupyterlab-pygments==0.2.2
108 markupsafe==2.1.2
108 markupsafe==2.1.2
109 mistune==2.0.5
109 mistune==2.0.5
110 nbclient==0.7.2
110 nbclient==0.7.2
111 jupyter_client==8.0.3
111 jupyter_client==8.0.3
112 jupyter_core==5.2.0
112 jupyter_core==5.2.0
113 platformdirs==3.1.0
113 platformdirs==3.1.0
114 traitlets==5.9.0
114 traitlets==5.9.0
115 python-dateutil==2.8.2
115 python-dateutil==2.8.2
116 six==1.16.0
116 six==1.16.0
117 pyzmq==25.0.0
117 pyzmq==25.0.0
118 tornado==6.2
118 tornado==6.2
119 traitlets==5.9.0
119 traitlets==5.9.0
120 jupyter_core==5.2.0
120 jupyter_core==5.2.0
121 platformdirs==3.1.0
121 platformdirs==3.1.0
122 traitlets==5.9.0
122 traitlets==5.9.0
123 nbformat==5.7.3
123 nbformat==5.7.3
124 fastjsonschema==2.16.3
124 fastjsonschema==2.16.3
125 jsonschema==4.17.3
125 jsonschema==4.17.3
126 attrs==22.2.0
126 attrs==22.2.0
127 pyrsistent==0.19.3
127 pyrsistent==0.19.3
128 jupyter_core==5.2.0
128 jupyter_core==5.2.0
129 platformdirs==3.1.0
129 platformdirs==3.1.0
130 traitlets==5.9.0
130 traitlets==5.9.0
131 traitlets==5.9.0
131 traitlets==5.9.0
132 traitlets==5.9.0
132 traitlets==5.9.0
133 nbformat==5.7.3
133 nbformat==5.7.3
134 fastjsonschema==2.16.3
134 fastjsonschema==2.16.3
135 jsonschema==4.17.3
135 jsonschema==4.17.3
136 attrs==22.2.0
136 attrs==22.2.0
137 pyrsistent==0.19.3
137 pyrsistent==0.19.3
138 jupyter_core==5.2.0
138 jupyter_core==5.2.0
139 platformdirs==3.1.0
139 platformdirs==3.1.0
140 traitlets==5.9.0
140 traitlets==5.9.0
141 traitlets==5.9.0
141 traitlets==5.9.0
142 packaging==23.0
142 packaging==23.0
143 pandocfilters==1.5.0
143 pandocfilters==1.5.0
144 pygments==2.14.0
144 pygments==2.14.0
145 tinycss2==1.2.1
145 tinycss2==1.2.1
146 webencodings==0.5.1
146 webencodings==0.5.1
147 traitlets==5.9.0
147 traitlets==5.9.0
148 orjson==3.8.7
148 pastescript==3.3.0
149 pastescript==3.3.0
149 paste==3.5.2
150 paste==3.5.2
150 six==1.16.0
151 six==1.16.0
151 pastedeploy==3.0.1
152 pastedeploy==3.0.1
152 six==1.16.0
153 six==1.16.0
153 pathlib2==2.3.7.post1
154 six==1.16.0
155 premailer==3.10.0
154 premailer==3.10.0
156 cachetools==5.3.0
155 cachetools==5.3.0
157 cssselect==1.2.0
156 cssselect==1.2.0
158 cssutils==2.6.0
157 cssutils==2.6.0
159 lxml==4.9.2
158 lxml==4.9.2
160 requests==2.28.2
159 requests==2.28.2
161 certifi==2022.12.7
160 certifi==2022.12.7
162 charset-normalizer==3.1.0
161 charset-normalizer==3.1.0
163 idna==3.4
162 idna==3.4
164 urllib3==1.26.14
163 urllib3==1.26.14
165 psutil==5.9.4
164 psutil==5.9.4
166 psycopg2==2.9.5
165 psycopg2==2.9.5
167 py-bcrypt==0.4
166 py-bcrypt==0.4
168 py-gfm==2.0.0
167 py-gfm==2.0.0
169 markdown==3.4.1
168 markdown==3.4.1
170 pycurl==7.45.2
169 pycurl==7.45.2
171 pycryptodome==3.17
170 pycryptodome==3.17
172 pymysql==1.0.2
171 pymysql==1.0.2
173 pyotp==2.8.0
172 pyotp==2.8.0
174 pyparsing==3.0.9
173 pyparsing==3.0.9
175 pyramid-debugtoolbar==4.10
174 pyramid-debugtoolbar==4.10
176 pygments==2.14.0
175 pygments==2.14.0
177 pyramid==2.0.1
176 pyramid==2.0.1
178 hupper==1.11
177 hupper==1.11
179 plaster==1.1.2
178 plaster==1.1.2
180 plaster-pastedeploy==1.0.1
179 plaster-pastedeploy==1.0.1
181 pastedeploy==3.0.1
180 pastedeploy==3.0.1
182 plaster==1.1.2
181 plaster==1.1.2
183 translationstring==1.4
182 translationstring==1.4
184 venusian==3.0.0
183 venusian==3.0.0
185 webob==1.8.7
184 webob==1.8.7
186 zope.deprecation==4.4.0
185 zope.deprecation==4.4.0
187 zope.interface==5.5.2
186 zope.interface==5.5.2
188 pyramid-mako==1.1.0
187 pyramid-mako==1.1.0
189 mako==1.2.4
188 mako==1.2.4
190 markupsafe==2.1.2
189 markupsafe==2.1.2
191 pyramid==2.0.1
190 pyramid==2.0.1
192 hupper==1.11
191 hupper==1.11
193 plaster==1.1.2
192 plaster==1.1.2
194 plaster-pastedeploy==1.0.1
193 plaster-pastedeploy==1.0.1
195 pastedeploy==3.0.1
194 pastedeploy==3.0.1
196 plaster==1.1.2
195 plaster==1.1.2
197 translationstring==1.4
196 translationstring==1.4
198 venusian==3.0.0
197 venusian==3.0.0
199 webob==1.8.7
198 webob==1.8.7
200 zope.deprecation==4.4.0
199 zope.deprecation==4.4.0
201 zope.interface==5.5.2
200 zope.interface==5.5.2
202 pyramid-mailer==0.15.1
201 pyramid-mailer==0.15.1
203 pyramid==2.0.1
202 pyramid==2.0.1
204 hupper==1.11
203 hupper==1.11
205 plaster==1.1.2
204 plaster==1.1.2
206 plaster-pastedeploy==1.0.1
205 plaster-pastedeploy==1.0.1
207 pastedeploy==3.0.1
206 pastedeploy==3.0.1
208 plaster==1.1.2
207 plaster==1.1.2
209 translationstring==1.4
208 translationstring==1.4
210 venusian==3.0.0
209 venusian==3.0.0
211 webob==1.8.7
210 webob==1.8.7
212 zope.deprecation==4.4.0
211 zope.deprecation==4.4.0
213 zope.interface==5.5.2
212 zope.interface==5.5.2
214 repoze.sendmail==4.4.1
213 repoze.sendmail==4.4.1
215 transaction==3.0.1
214 transaction==3.0.1
216 zope.interface==5.5.2
215 zope.interface==5.5.2
217 zope.interface==5.5.2
216 zope.interface==5.5.2
218 transaction==3.0.1
217 transaction==3.0.1
219 zope.interface==5.5.2
218 zope.interface==5.5.2
220 python-ldap==3.4.3
219 python-ldap==3.4.3
221 pyasn1==0.4.8
220 pyasn1==0.4.8
222 pyasn1-modules==0.2.8
221 pyasn1-modules==0.2.8
223 pyasn1==0.4.8
222 pyasn1==0.4.8
224 python-memcached==1.59
223 python-memcached==1.59
225 six==1.16.0
224 six==1.16.0
226 python-pam==2.0.2
225 python-pam==2.0.2
227 python3-saml==1.15.0
226 python3-saml==1.15.0
228 isodate==0.6.1
227 isodate==0.6.1
229 six==1.16.0
228 six==1.16.0
230 lxml==4.9.2
229 lxml==4.9.2
231 xmlsec==1.3.13
230 xmlsec==1.3.13
232 lxml==4.9.2
231 lxml==4.9.2
233 pyyaml==6.0
232 pyyaml==6.0
234 redis==4.5.1
233 redis==4.5.1
235 async-timeout==4.0.2
234 async-timeout==4.0.2
236 regex==2022.10.31
235 regex==2022.10.31
237 routes==2.5.1
236 routes==2.5.1
238 repoze.lru==0.7
237 repoze.lru==0.7
239 six==1.16.0
238 six==1.16.0
240 simplejson==3.18.3
239 simplejson==3.18.3
241 sshpubkeys==3.3.1
240 sshpubkeys==3.3.1
242 cryptography==39.0.2
241 cryptography==39.0.2
243 cffi==1.15.1
242 cffi==1.15.1
244 pycparser==2.21
243 pycparser==2.21
245 ecdsa==0.18.0
244 ecdsa==0.18.0
246 six==1.16.0
245 six==1.16.0
247 supervisor==4.2.5
246 supervisor==4.2.5
248 tzlocal==4.2
247 tzlocal==4.2
249 pytz-deprecation-shim==0.1.0.post0
248 pytz-deprecation-shim==0.1.0.post0
250 tzdata==2022.7
249 tzdata==2022.7
251 urlobject==2.4.3
250 urlobject==2.4.3
252 waitress==2.1.2
251 waitress==2.1.2
253 weberror==0.13.1
252 weberror==0.13.1
254 paste==3.5.2
253 paste==3.5.2
255 six==1.16.0
254 six==1.16.0
256 pygments==2.14.0
255 pygments==2.14.0
257 tempita==0.5.2
256 tempita==0.5.2
258 webob==1.8.7
257 webob==1.8.7
259 webhelpers2==2.0
258 webhelpers2==2.0
260 markupsafe==2.1.2
259 markupsafe==2.1.2
261 six==1.16.0
260 six==1.16.0
262 whoosh==2.7.4
261 whoosh==2.7.4
263 zope.cachedescriptors==4.4
262 zope.cachedescriptors==4.4
264
263
265 ## uncomment to add the debug libraries
264 ## uncomment to add the debug libraries
266 #-r requirements_debug.txt
265 #-r requirements_debug.txt
@@ -1,64 +1,83 b''
1 import datetime
1 import datetime
2 import decimal
2 import decimal
3 import functools
3 import functools
4 # we keep simplejson for having dump functionality still
5 # orjson doesn't support it
6 import orjson
7 import simplejson
8 import orjson as json
4
9
5 import simplejson as json
6
10
7 from rhodecode.lib.datelib import is_aware
11 from rhodecode.lib.datelib import is_aware
12 from rhodecode.lib.str_utils import safe_str
8
13
9 try:
14 try:
10 import rhodecode.translation
15 import rhodecode.translation
11 except ImportError:
16 except ImportError:
12 rhodecode = None
17 rhodecode = None
13
18
14 __all__ = ['json']
19 __all__ = ['json']
15
20
16
21
17 def _obj_dump(obj):
22 def _obj_dump(obj):
18 """
23 """
19 Custom function for dumping objects to JSON, if obj has __json__ attribute
24 Custom function for dumping objects to JSON, if obj has __json__ attribute
20 or method defined it will be used for serialization
25 or method defined it will be used for serialization
21
26
22 :param obj:
27 :param obj:
23 """
28 """
24
29
25 # See "Date Time String Format" in the ECMA-262 specification.
30 # See "Date Time String Format" in the ECMA-262 specification.
26 # some code borrowed from django 1.4
31 # some code borrowed from django 1.4
27 if isinstance(obj, set):
32 if isinstance(obj, set):
28 return list(obj)
33 return list(obj)
29 elif isinstance(obj, datetime.datetime):
34 elif isinstance(obj, datetime.datetime):
30 r = obj.isoformat()
35 r = obj.isoformat()
31 if isinstance(obj.microsecond, int):
36 if isinstance(obj.microsecond, int):
32 r = r[:23] + r[26:]
37 r = r[:23] + r[26:]
33 if r.endswith('+00:00'):
38 if r.endswith('+00:00'):
34 r = r[:-6] + 'Z'
39 r = r[:-6] + 'Z'
35 return r
40 return r
36 elif isinstance(obj, datetime.date):
41 elif isinstance(obj, datetime.date):
37 return obj.isoformat()
42 return obj.isoformat()
38 elif isinstance(obj, datetime.time):
43 elif isinstance(obj, datetime.time):
39 if is_aware(obj):
44 if is_aware(obj):
40 raise TypeError("Time-zone aware times are not JSON serializable")
45 raise TypeError("Time-zone aware times are not JSON serializable")
41 r = obj.isoformat()
46 r = obj.isoformat()
42 if isinstance(obj.microsecond, int):
47 if isinstance(obj.microsecond, int):
43 r = r[:12]
48 r = r[:12]
44 return r
49 return r
45 elif hasattr(obj, '__json__'):
50 elif hasattr(obj, '__json__'):
46 if callable(obj.__json__):
51 if callable(obj.__json__):
47 return obj.__json__()
52 return obj.__json__()
48 else:
53 else:
49 return obj.__json__
54 return obj.__json__
50 elif isinstance(obj, decimal.Decimal):
55 elif isinstance(obj, decimal.Decimal):
51 return str(obj)
56 return str(obj)
52 elif isinstance(obj, complex):
57 elif isinstance(obj, complex):
53 return [obj.real, obj.imag]
58 return [obj.real, obj.imag]
54 elif rhodecode and isinstance(obj, rhodecode.translation._LazyString):
59 elif rhodecode and isinstance(obj, rhodecode.translation._LazyString):
55 return obj.eval()
60 return obj.eval()
56 else:
61 else:
57 raise TypeError(repr(obj) + " is not JSON serializable")
62 raise TypeError(repr(obj) + " is not JSON serializable")
58
63
59
64
60 json.dumps = functools.partial(json.dumps, default=_obj_dump, use_decimal=False)
65 json.dumps = functools.partial(json.dumps, default=_obj_dump, option=orjson.OPT_NON_STR_KEYS)
61 json.dump = functools.partial(json.dump, default=_obj_dump, use_decimal=False)
66 json.dump = functools.partial(simplejson.dump, default=_obj_dump)
67
68
69 def formatted_json(*args, **kwargs):
70 # alias for formatted json
71 opts = orjson.OPT_NON_STR_KEYS | orjson.OPT_INDENT_2 | orjson.OPT_SORT_KEYS
72 return functools.partial(json.dumps, option=opts)(*args, **kwargs)
73
62
74
63 # alias for formatted json
75 def formatted_str_json(*args, **kwargs):
64 formatted_json = functools.partial(json.dumps, indent=4, sort_keys=True)
76 opts = orjson.OPT_NON_STR_KEYS | orjson.OPT_INDENT_2 | orjson.OPT_SORT_KEYS
77 closure = functools.partial(json.dumps, option=opts)
78 return safe_str(closure(*args, **kwargs))
79
80
81 def str_json(*args, **kwargs):
82 closure = functools.partial(json.dumps)
83 return safe_str(closure(*args, **kwargs))
General Comments 0
You need to be logged in to leave comments. Login now