python: improve code readability of packing.py functions