PERF: avoid object-dtype comparisons
State: closed

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.

Labels:
name: Performance
description: Memory or execution speed performance
name: Dtype Conversions
description: Unexpected or buggy dtype conversions

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=h1) Report
> Merging [#24792](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/02b5d9f509cd20dcaf08d65844f270439767dbb4?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `85.71%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/24792/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=tree)

```diff
@@            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%)` | :arrow_down: |
| #single | `42.92% <57.14%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24792/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.04% <100%> (-0.06%)` | :arrow_down: |
| [pandas/core/internals/blocks.py](https://codecov.io/gh/pandas-dev/pandas/pull/24792/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2Jsb2Nrcy5weQ==) | `94.26% <75%> (-0.06%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=footer). Last update [02b5d9f...e095069](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=h1) Report
> Merging [#24792](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/02b5d9f509cd20dcaf08d65844f270439767dbb4?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `85.71%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/24792/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=tree)

```diff
@@            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%)` | :arrow_down: |
| #single | `42.92% <57.14%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24792/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.04% <100%> (-0.06%)` | :arrow_down: |
| [pandas/core/internals/blocks.py](https://codecov.io/gh/pandas-dev/pandas/pull/24792/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2Jsb2Nrcy5weQ==) | `94.26% <75%> (-0.06%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=footer). Last update [02b5d9f...e095069](https://codecov.io/gh/pandas-dev/pandas/pull/24792?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

thanks!