Skip to content

PERF: avoid object-dtype comparisons #24792

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

Merged
merged 1 commit into from
Jan 16, 2019
Merged

Conversation

jbrockmendel
Copy link
Member

Looking at the --durations=10 results in the tests, one that stands out is

7.08s call     pandas/tests/series/test_datetime_values.py::TestSeriesDatetimeValues::test_dt_namespace_accessor

It turns out all but about 0.15 seconds of this is spent in a tm.assert_series_equal call for a Datetime64TZ Series. Tracking that down, its in array_equivalent, which casts to object-dtype before comparing. This avoids that casting, shaves almost 7 seconds off that test.

@codecov
Copy link

codecov bot commented Jan 16, 2019

Codecov Report

Merging #24792 into master will decrease coverage by <.01%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24792      +/-   ##
==========================================
- Coverage   92.38%   92.38%   -0.01%     
==========================================
  Files         166      166              
  Lines       52375    52382       +7     
==========================================
+ Hits        48389    48394       +5     
- Misses       3986     3988       +2
Flag Coverage Δ
#multiple 90.81% <85.71%> (-0.01%) ⬇️
#single 42.92% <57.14%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/util/testing.py 88.04% <100%> (-0.06%) ⬇️
pandas/core/internals/blocks.py 94.26% <75%> (-0.06%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 02b5d9f...e095069. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Jan 16, 2019

Codecov Report

Merging #24792 into master will decrease coverage by <.01%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24792      +/-   ##
==========================================
- Coverage   92.38%   92.38%   -0.01%     
==========================================
  Files         166      166              
  Lines       52375    52382       +7     
==========================================
+ Hits        48389    48394       +5     
- Misses       3986     3988       +2
Flag Coverage Δ
#multiple 90.81% <85.71%> (-0.01%) ⬇️
#single 42.92% <57.14%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/util/testing.py 88.04% <100%> (-0.06%) ⬇️
pandas/core/internals/blocks.py 94.26% <75%> (-0.06%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 02b5d9f...e095069. Read the comment docs.

@@ -2465,6 +2465,12 @@ def setitem(self, indexer, value):
klass=ObjectBlock,)
return newb.setitem(indexer, value)

def equals(self, other):
# override for significant performance improvement
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would u do this here and not in array_equivalent

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because array_equivalent's docstring specifically says it assumes it is dealing with numpy arrays

@jreback jreback added the Performance Memory or execution speed performance label Jan 16, 2019
@jreback jreback added this to the 0.24.0 milestone Jan 16, 2019
@jreback jreback added the Dtype Conversions Unexpected or buggy dtype conversions label Jan 16, 2019
@jreback jreback merged commit 57a6f44 into pandas-dev:master Jan 16, 2019
@jreback
Copy link
Contributor

jreback commented Jan 16, 2019

thanks!

@jbrockmendel jbrockmendel deleted the dfred branch January 16, 2019 02:57
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants