@@ -29,7 +29,16 @@ pub fn create_object(type_type: PyObjectRef, object_type: PyObjectRef, dict_type
29
29
( * object_type. borrow_mut ( ) ) . typ = Some ( type_type. clone ( ) ) ;
30
30
}
31
31
32
- fn obj_str ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
32
+ fn object_eq ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
33
+ arg_check ! (
34
+ vm,
35
+ args,
36
+ required = [ ( zelf, Some ( vm. ctx. object( ) ) ) , ( other, None ) ]
37
+ ) ;
38
+ Ok ( vm. ctx . new_bool ( zelf. is ( other) ) )
39
+ }
40
+
41
+ fn object_str ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
33
42
arg_check ! ( vm, args, required = [ ( obj, Some ( vm. ctx. object( ) ) ) ] ) ;
34
43
let type_name = objtype:: get_type_name ( & obj. typ ( ) ) ;
35
44
let address = obj. get_id ( ) ;
@@ -39,8 +48,9 @@ fn obj_str(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
39
48
pub fn init ( context : & PyContext ) {
40
49
let ref object = context. object ;
41
50
object. set_attr ( "__new__" , context. new_rustfunc ( new_instance) ) ;
51
+ object. set_attr ( "__eq__" , context. new_rustfunc ( object_eq) ) ;
42
52
object. set_attr ( "__dict__" , context. new_member_descriptor ( object_dict) ) ;
43
- object. set_attr ( "__str__" , context. new_rustfunc ( obj_str ) ) ;
53
+ object. set_attr ( "__str__" , context. new_rustfunc ( object_str ) ) ;
44
54
}
45
55
46
56
fn object_dict ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
0 commit comments