-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: DatetimeIndex.__iter__ creates a temp array of Timestamp (GH7683) #7709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -333,3 +333,28 @@ def date_range(start=None, end=None, periods=None, freq=None): | |
|
||
timeseries_is_month_start = Benchmark('rng.is_month_start', setup, | ||
start_date=datetime(2014, 4, 1)) | ||
|
||
#---------------------------------------------------------------------- | ||
# iterate over DatetimeIndex/PeriodIndex | ||
setup = common_setup + """ | ||
N = 1000000 | ||
M = 10000 | ||
idx1 = date_range(start='20140101', freq='T', periods=N) | ||
idx2 = period_range(start='20140101', freq='T', periods=N) | ||
|
||
def iter_n(iterable, n=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you don't need this, the vbench will run on different versions |
||
i = 0 | ||
for _ in iterable: | ||
i += 1 | ||
if n is not None and i > n: | ||
break | ||
""" | ||
|
||
timeseries_iter_datetimeindex = Benchmark('iter_n(idx1)', setup) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just use |
||
|
||
timeseries_iter_periodindex = Benchmark('iter_n(idx2)', setup) | ||
|
||
timeseries_iter_datetimeindex_preexit = Benchmark('iter_n(idx1, M)', setup) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you don't need these last 2 (the first 2 will suffice) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the change fixes setup time and memory for iterator but it uses a bit more time when iterating over the whole list. the first two tests cover full iteration while the last two cover partial iteration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I c what you are going for, ok then! (though I would still use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iter(idx1) is basically partial iteration with non element iterated. |
||
|
||
timeseries_iter_periodindex_preexit = Benchmark('iter_n(idx2, M)', setup) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using the smaller is fine