@@ -6,7 +6,7 @@ use core::ffi::c_void;
6
6
use core:: ffi:: CStr ;
7
7
#[ cfg( feature = "yyjson" ) ]
8
8
use core:: mem:: MaybeUninit ;
9
- use core:: ptr:: { null , null_mut, NonNull } ;
9
+ use core:: ptr:: { null_mut, NonNull } ;
10
10
use once_cell:: race:: { OnceBool , OnceBox } ;
11
11
12
12
#[ cfg( feature = "yyjson" ) ]
@@ -144,37 +144,33 @@ fn _init_typerefs_impl() -> bool {
144
144
crate :: serialize:: writer:: set_str_formatter_fn ( ) ;
145
145
crate :: str:: set_str_create_fn ( ) ;
146
146
147
- FRAGMENT_TYPE = orjson_fragmenttype_new ( ) ;
148
- PyDateTime_IMPORT ( ) ;
149
147
NONE = Py_None ( ) ;
150
148
TRUE = Py_True ( ) ;
151
149
FALSE = Py_False ( ) ;
152
150
EMPTY_UNICODE = PyUnicode_New ( 0 , 255 ) ;
153
- STR_TYPE = ( * EMPTY_UNICODE ) . ob_type ;
154
- BYTES_TYPE = ( * PyBytes_FromStringAndSize ( null ( ) , 0 ) ) . ob_type ;
155
151
156
- {
157
- let bytearray = PyByteArray_FromStringAndSize ( null ( ) , 0 ) ;
158
- BYTEARRAY_TYPE = ( * bytearray) . ob_type ;
152
+ STR_TYPE = & raw mut PyUnicode_Type ;
153
+ BYTES_TYPE = & raw mut PyBytes_Type ;
154
+ DICT_TYPE = & raw mut PyDict_Type ;
155
+ LIST_TYPE = & raw mut PyList_Type ;
156
+ TUPLE_TYPE = & raw mut PyTuple_Type ;
157
+ NONE_TYPE = ( * NONE ) . ob_type ;
158
+ BOOL_TYPE = & raw mut PyBool_Type ;
159
+ INT_TYPE = & raw mut PyLong_Type ;
160
+ FLOAT_TYPE = & raw mut PyFloat_Type ;
161
+ BYTEARRAY_TYPE = & raw mut PyByteArray_Type ;
162
+ MEMORYVIEW_TYPE = & raw mut PyMemoryView_Type ;
159
163
160
- let memoryview = PyMemoryView_FromObject ( bytearray) ;
161
- MEMORYVIEW_TYPE = ( * memoryview) . ob_type ;
162
- Py_DECREF ( memoryview) ;
163
- Py_DECREF ( bytearray) ;
164
- }
164
+ PyDateTime_IMPORT ( ) ;
165
165
166
- DICT_TYPE = ( * PyDict_New ( ) ) . ob_type ;
167
- LIST_TYPE = ( * PyList_New ( 0 ) ) . ob_type ;
168
- TUPLE_TYPE = ( * PyTuple_New ( 0 ) ) . ob_type ;
169
- NONE_TYPE = ( * NONE ) . ob_type ;
170
- BOOL_TYPE = ( * TRUE ) . ob_type ;
171
- INT_TYPE = ( * PyLong_FromLongLong ( 0 ) ) . ob_type ;
172
- FLOAT_TYPE = ( * PyFloat_FromDouble ( 0.0 ) ) . ob_type ;
173
166
DATETIME_TYPE = look_up_datetime_type ( ) ;
174
167
DATE_TYPE = look_up_date_type ( ) ;
175
168
TIME_TYPE = look_up_time_type ( ) ;
176
169
UUID_TYPE = look_up_uuid_type ( ) ;
177
170
ENUM_TYPE = look_up_enum_type ( ) ;
171
+
172
+ FRAGMENT_TYPE = orjson_fragmenttype_new ( ) ;
173
+
178
174
FIELD_TYPE = look_up_field_type ( ) ;
179
175
ZONEINFO_TYPE = look_up_zoneinfo_type ( ) ;
180
176
0 commit comments