https://github.com/houtianze/bypy/blob/master/bypy.py