[mpg-b.py] python reimplementation