PERF: Use searchsorted instead of get_loc.

On pandas < 18, `get_loc` triggers allocation of a large hash table, so
we don't want to call get_loc on minutely `DatetimeIndex`es.
This commit is contained in:
Scott Sanderson
2016-11-22 12:33:58 -05:00
parent 52ed9093eb
commit 8aacac1cb6
+3 -3
View File
@@ -380,7 +380,7 @@ class HistoryLoader(with_metaclass(ABCMeta)):
assets = self._asset_finder.retrieve_all(assets)
try:
end_ix = self._calendar.get_loc(end)
end_ix = self._calendar.searchsorted(end)
except KeyError:
raise KeyError("{0} not in calendar [{1}...{2}]".format(
end, self._calendar[0], self._calendar[-1]))
@@ -405,7 +405,7 @@ class HistoryLoader(with_metaclass(ABCMeta)):
offset = 0
try:
start_ix = self._calendar.get_loc(start)
start_ix = self._calendar.searchsorted(start)
except KeyError:
raise KeyError("{0} not in calendar [{1}...{2}]".format(
start, self._calendar[0], self._calendar[-1]))
@@ -537,7 +537,7 @@ class HistoryLoader(with_metaclass(ABCMeta)):
dts,
field,
is_perspective_after)
end_ix = self._calendar.get_loc(dts[-1])
end_ix = self._calendar.searchsorted(dts[-1])
return concatenate(
[window.get(end_ix) for window in block],