Rewrite PL/Python's typeio logic

Rewrite PL/Python's typeio logic

Edit