refactoring pyobject