Refactoring python bindings