python: implement stats