astropy/astropy — pull request #1933 by mdboom (2014-01-06 22:00:45+00:00)
Title: Creating TimeDeltas is now extremely slow

After the merge of changes from #1870 creating a TimeDelta object from a Quantity just became REALLY slow:

Using the latest (commit 50289dd73e1d4053baaac9edf77748442af1f826):
```
In [1]: import astropy.units as u

In [2]: import astropy.time as t

In [3]: time for i in range(1000): dt = t.TimeDelta(1.0*u.us)
CPU times: user 21.14 s, sys: 0.02 s, total: 21.16 s
Wall time: 21.16 s
```

Using the most recent previous version (commit 4bdee60b0bac8bff843cb0efab0b193d18a64571):
```
In [1]: import astropy.units as u

In [2]: import astropy.time as t

In [3]: time for i in range(1000): dt = t.TimeDelta(1.0*u.us)
CPU times: user 0.40 s, sys: 0.00 s, total: 0.41 s
Wall time: 0.40 s
```

I poked around with a profiler a bit, and it is spending most of the time in the new did_you_mean() function in utils/misc.py. But I haven't really been able to see why the TimeDelta init routines are triggering the unit name mismatch code. @taldcroft or @mhvk - maybe one of you know why?

Thanks!