python implement of bwt compression