File tree 2 files changed +12
-9
lines changed 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ from asyncpg.pgproto import pgproto
9
9
from dataclasses import _MISSING_TYPE, MISSING
10
10
from typing import Any, Union
11
11
from decimal import Decimal
12
- from datamodel.exceptions cimport ParserError
12
+ from ..exceptions cimport ParserError
13
+ from ..fields import Field
13
14
import orjson
14
15
15
16
@@ -45,6 +46,8 @@ cdef class JSONContent:
45
46
return None
46
47
elif obj is MISSING:
47
48
return None
49
+ elif isinstance (obj, Field):
50
+ return obj.to_dict()
48
51
raise TypeError (f" {obj!r} is not JSON serializable" )
49
52
50
53
def encode (self , object obj , **kwargs ) -> str:
Original file line number Diff line number Diff line change 6
6
# from datamodel.libs.mapping import ClassDict
7
7
from datamodel .libs .mutables import ClassDict
8
8
9
+
10
+ runner = pyperf .Runner ()
9
11
class QueryObject (ClassDict ):
10
12
"""Base Class for all options passed to Parsers.
11
13
"""
@@ -39,16 +41,14 @@ def create_models():
39
41
40
42
41
43
print ('=== TESTING CREATION OF DICT === ' )
42
- time = timeit .timeit (create_dicts , number = 10000 )
44
+ time = timeit .timeit (create_dicts , number = 1000 )
43
45
print (f"Execution time: { time :.6f} seconds" )
44
46
print ('===' )
45
- runner = pyperf .Runner ()
46
47
runner .bench_func ('create_objects' , create_dicts )
47
48
48
49
49
- # print('=== TESTING CREATION OF MODEL === ')
50
- # time = timeit.timeit(create_models, number=10000)
51
- # print(f"Execution time: {time:.6f} seconds")
52
- # print('===')
53
- # runner = pyperf.Runner()
54
- # runner.bench_func('create_models', create_models)
50
+ print ('=== TESTING CREATION OF MODEL === ' )
51
+ time = timeit .timeit (create_models , number = 1000 )
52
+ print (f"Execution time: { time :.6f} seconds" )
53
+ print ('===' )
54
+ runner .bench_func ('create_models' , create_models )
You can’t perform that action at this time.
0 commit comments