@@ -64,24 +64,15 @@ pub enum IsType {
6464impl ObTypeLookup {
6565 fn new ( py : Python ) -> Self {
6666 // todo: delete before PR ready
67- println ! ( "[RUST] ObTypeLookup::new" ) ;
6867 Self {
6968 none : PyNone :: type_object_raw ( py) as usize ,
7069 int : PyInt :: type_object_raw ( py) as usize ,
7170 bool : PyBool :: type_object_raw ( py) as usize ,
7271 float : PyFloat :: type_object_raw ( py) as usize ,
7372 list : PyList :: type_object_raw ( py) as usize ,
7473 dict : PyDict :: type_object_raw ( py) as usize ,
75- decimal_object : {
76- // todo: delete before PR ready
77- println ! ( "[RUST] ObTypeLookup::new - loading decimal_object" ) ;
78- py. import ( "decimal" ) . unwrap ( ) . getattr ( "Decimal" ) . unwrap ( ) . unbind ( )
79- } ,
80- fraction_object : {
81- // todo: delete before PR ready
82- println ! ( "[RUST] ObTypeLookup::new - loading fraction_object" ) ;
83- py. import ( "fractions" ) . unwrap ( ) . getattr ( "Fraction" ) . unwrap ( ) . unbind ( )
84- } ,
74+ decimal_object : py. import ( "decimal" ) . unwrap ( ) . getattr ( "Decimal" ) . unwrap ( ) . unbind ( ) ,
75+ fraction_object : py. import ( "fractions" ) . unwrap ( ) . getattr ( "Fraction" ) . unwrap ( ) . unbind ( ) ,
8576 string : PyString :: type_object_raw ( py) as usize ,
8677 bytes : PyBytes :: type_object_raw ( py) as usize ,
8778 bytearray : PyByteArray :: type_object_raw ( py) as usize ,
@@ -108,7 +99,6 @@ impl ObTypeLookup {
10899 }
109100
110101 pub fn is_type ( & self , value : & Bound < ' _ , PyAny > , expected_ob_type : ObType ) -> IsType {
111- println ! ( "[RUST] is_type - expected_ob_type: {expected_ob_type}" ) ;
112102 match self . ob_type_is_expected ( Some ( value) , & value. get_type ( ) , & expected_ob_type) {
113103 IsType :: False => {
114104 if expected_ob_type == self . fallback_isinstance ( value) {
@@ -129,7 +119,6 @@ impl ObTypeLookup {
129119 ) -> IsType {
130120 let type_ptr = py_type. as_ptr ( ) ;
131121 let ob_type = type_ptr as usize ;
132- println ! ( "[RUST] ob_type_is_expected - ob_type: {ob_type}, expected_ob_type: {expected_ob_type}" ) ;
133122 let ans = match expected_ob_type {
134123 ObType :: None => self . none == ob_type,
135124 ObType :: Int => self . int == ob_type,
@@ -151,16 +140,8 @@ impl ObTypeLookup {
151140 ObType :: Str => self . string == ob_type,
152141 ObType :: List => self . list == ob_type,
153142 ObType :: Dict => self . dict == ob_type,
154- ObType :: Decimal => {
155- // todo: delete before PR ready
156- println ! ( "[RUST] ob_type_is_expected - checking ObType::Decimal" ) ;
157- self . decimal_object . as_ptr ( ) as usize == ob_type
158- } ,
159- ObType :: Fraction => {
160- // todo: delete before PR ready
161- println ! ( "[RUST] ob_type_is_expected - checking ObType::Fraction" ) ;
162- self . fraction_object . as_ptr ( ) as usize == ob_type
163- } ,
143+ ObType :: Decimal => self . decimal_object . as_ptr ( ) as usize == ob_type,
144+ ObType :: Fraction => self . fraction_object . as_ptr ( ) as usize == ob_type,
164145 ObType :: StrSubclass => self . string == ob_type && op_value. is_none ( ) ,
165146 ObType :: Tuple => self . tuple == ob_type,
166147 ObType :: Set => self . set == ob_type,
@@ -237,12 +218,8 @@ impl ObTypeLookup {
237218 } else if ob_type == self . dict {
238219 ObType :: Dict
239220 } else if ob_type == self . decimal_object . as_ptr ( ) as usize {
240- // todo: delete before PR ready
241- println ! ( "[RUST] lookup_by_ob_type - found ObType::Decimal" ) ;
242221 ObType :: Decimal
243222 } else if ob_type == self . fraction_object . as_ptr ( ) as usize {
244- // todo: delete before PR ready
245- println ! ( "[RUST] lookup_by_ob_type - found ObType::Fraction" ) ;
246223 ObType :: Fraction
247224 } else if ob_type == self . bytes {
248225 ObType :: Bytes
@@ -351,12 +328,8 @@ impl ObTypeLookup {
351328 } else if value. is_instance_of :: < PyMultiHostUrl > ( ) {
352329 ObType :: MultiHostUrl
353330 } else if value. is_instance ( self . decimal_object . bind ( py) ) . unwrap_or ( false ) {
354- // todo: delete before PR ready
355- println ! ( "[RUST] fallback_isinstance - found ObType::Decimal" ) ;
356331 ObType :: Decimal
357332 } else if value. is_instance ( self . fraction_object . bind ( py) ) . unwrap_or ( false ) {
358- // todo: delete before PR ready
359- println ! ( "[RUST] fallback_isinstance - found ObType::Fraction" ) ;
360333 ObType :: Fraction
361334 } else if value. is_instance ( self . uuid_object . bind ( py) ) . unwrap_or ( false ) {
362335 ObType :: Uuid
0 commit comments