refine python packing