Improve performance in validateinterfaces.py.