Refactor with _compat.py