Closed
Description
For now, Object protocol methods are (mostly) thin wrapper of matching vm functions. Because we don't need to have duplicated functions for same features, they need to be moved from vm to object protocol functions.
vm
path:vm/src/vm.rs
- object protocol path:
vm/src/protocol/object.rs
The matching vm functions are easy to find because object methods are calling it.
- get_attr Relocate
vm.get_attribute
toobj.get_attr
#3331 - set_attr Relocate
vm.set_attr
toobj.set_attr
#3338 - del_attr Relocate
vm.del_attr
toobj.del_attr
#3341 - rich_compare Relocate
vm.rich_compare
toobj.rich_compare
#3347 - repr Relocate
vm.to_repr
toobject.repr
#3364 - str Relocate
vm.to_str
toobj.str
#3349 - is_subclass Relocate vm.issubclass to obj.is_subclass #3345
- is_instance Relocate vm.isinstance to obj.is_instance #3344
- hash Relocate vm._hash to obj.hash #3342
- length Relocate vm.obj_len to obj.length #3343
Becasue relocating each function will cause many code editing, every new PR for each function is recommended for easier review.
Reference:
- Object protocol #3306: The original patch to add object protocol