Use hasattr instead of dir

`dir()` is insanely slow since it has to create and sort a list each time. Switching to `hasattr` provides a nice 10x speedup.
Merge pull request #59 from signed0/patch-1

Use hasattr instead of dir