optimize readAttribute.py