CategoricalDtype construction: actually use fastpath
State: closed

cc @TomAugspurger the current `CategoricalDtype._from_fastpath(..)` was not any different from `CategoricalDtype(..)` as far as I could see, as the `fastpath` argument in `_finalize` was not used. This seems the logical fix.

Labels:
name: Internals
description: Related to non-user accessible pandas implementation
name: Categorical
description: Categorical Data Type

Comments:
passing dtype averts the need for fastpath
That may be, but I suppose `CategoricalDtype._from_fastpath(cats)` exists for a reason? Currently it does exactly the same as `CategoricalDtype(cats)` because the kwarg is not passed through. 
Note this is not `fastpath` in the `Categorical` constructor (https://github.com/pandas-dev/pandas/issues/17562) but the internal `_from_fastpath` method
we shouldn’t have both (and deprecating fastpath=True)
so the constructor ._from_fastpath is a better usage generally 
> so the constructor ._from_fastpath is a better usage generally

Sorry, Jeff, I really don't follow your comments. Please look at the diff / my explanation. It is exactly `_from_fastpath` that I am fixing, so what is the point you are trying to make?
hah didn’t see that

better to pass in dtype then as it’s the fastpath anyhow
I think the point of `_from_fastpath` is to have a fastpath when starting from (known-to-be-valid) categories, not a dtype. As to pass a dtype as fastpath, you still first have to create the dtype :-)
> I think the point of _from_fastpath is to have a fastpath when starting from (known-to-be-valid) categories, not a dtype. As to pass a dtype as fastpath, you still first have to create the dtype :-)

exactly the point. you should create the dtype and pass it (this is the general soln to removing the ``fastpath`` kw anyhow
> exactly the point. you should create the dtype and pass it

So how does this relate to this PR? As this PR exactly deals with this creation of the dtype. 
Or do you mean: yes, this is something we should do more so this PR is fine! If so please say so :-) If not, please look at the diff (expand it a bit too above, so you see the actual `_from_fastpath` method where '_finalize' is used), and give a more specific comment.
actually this is ok. sorry was looking at something else.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17891?src=pr&el=h1) Report
> Merging [#17891](https://codecov.io/gh/pandas-dev/pandas/pull/17891?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/34978a72107b3c77cf295fadbf1f5244ccb6afdf?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #17891      +/-   ##
==========================================
- Coverage   91.26%   91.24%   -0.02%     
==========================================
  Files         163      163              
  Lines       50105    50105              
==========================================
- Hits        45727    45718       -9     
- Misses       4378     4387       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.05% <100%> (ø)` | :arrow_up: |
| #single | `40.31% <100%> (-0.06%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17891?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/dtypes/dtypes.py](https://codecov.io/gh/pandas-dev/pandas/pull/17891?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2R0eXBlcy5weQ==) | `95.14% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17891?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17891?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.75% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17891?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/17891?src=pr&el=footer). Last update [34978a7...e883b3b](https://codecov.io/gh/pandas-dev/pandas/pull/17891?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/17891?src=pr&el=h1) Report
> Merging [#17891](https://codecov.io/gh/pandas-dev/pandas/pull/17891?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/34978a72107b3c77cf295fadbf1f5244ccb6afdf?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #17891      +/-   ##
==========================================
- Coverage   91.26%   91.24%   -0.02%     
==========================================
  Files         163      163              
  Lines       50105    50105              
==========================================
- Hits        45727    45718       -9     
- Misses       4378     4387       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.05% <100%> (ø)` | :arrow_up: |
| #single | `40.31% <100%> (-0.06%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17891?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/dtypes/dtypes.py](https://codecov.io/gh/pandas-dev/pandas/pull/17891?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2R0eXBlcy5weQ==) | `95.14% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17891?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17891?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.75% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17891?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/17891?src=pr&el=footer). Last update [34978a7...e883b3b](https://codecov.io/gh/pandas-dev/pandas/pull/17891?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Thanks @jorisvandenbossche, sorry I missed that earlier.