File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -62,21 +62,17 @@ fn get_ordered_dict_type(py: Python<'_>) -> &Bound<'_, PyType> {
62
62
. bind ( py)
63
63
}
64
64
65
- // Ultra-fast OrderedDict detection with multiple optimization layers
66
65
fn check_if_ordered_dict ( obj : & Bound < ' _ , PyAny > ) -> bool {
67
- // FASTEST PATH: Check if it's exact PyDict first - skip everything for regular dicts
68
66
if obj. is_exact_instance_of :: < PyDict > ( ) {
69
- return false ; // Regular dict - absolutely not OrderedDict
67
+ return false ;
70
68
}
71
69
72
- // FAST PATH: Quick type name check - avoid Python import if possible
73
70
if let Ok ( type_name) = obj. get_type ( ) . name ( ) {
74
71
if type_name. to_string ( ) != "OrderedDict" {
75
- return false ; // Not OrderedDict based on name
72
+ return false ;
76
73
}
77
74
}
78
75
79
- // SLOW PATH: Only for actual OrderedDict objects - expensive type lookup
80
76
let ordered_dict_type = get_ordered_dict_type ( obj. py ( ) ) ;
81
77
obj. is_instance ( ordered_dict_type) . unwrap_or ( false )
82
78
}
@@ -432,6 +428,7 @@ impl<'py> Input<'py> for Bound<'py, PyAny> {
432
428
}
433
429
434
430
fn lax_dict < ' a > ( & ' a self ) -> ValResult < GenericPyMapping < ' a , ' py > > {
431
+
435
432
if check_if_ordered_dict ( self ) {
436
433
// OrderedDict is a subclass of dict, but we want to treat it as a mapping to preserve order
437
434
if let Ok ( mapping) = self . downcast :: < PyMapping > ( ) {
You can’t perform that action at this time.
0 commit comments