CLN: Cython Py2/3 Compatible Imports
State: closed

- [ ] progress towards #23927
- [ ] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

@jbrockmendel 


Labels:
name: Clean

Comments:
Hello @WillAyd! Thanks for submitting the PR.

 - There are no PEP8 issues in the file [`setup.py`](https://github.com/WillAyd/pandas/blob/62bee57d0fc07c35bd4b89cb18a3dd99aec0dc3e/setup.py) !


Main things needed to make this work were:

1. Changing import machinery (95%)
2. Handling difference in division (5%)
3. Removed unicode from fused type with string / bytes object

Not entirely sure of the impact of the last. There is an alternate language setting in Cython we could use which uses Python3 but maintains 2 unicode semantics if this doesn't end up passing
How strongly do you feel about absolute vs relative imports?  These get pretty verbose.
Definitely more verbose but since we tend to favor absolute in the rest of the code base I think the consistency here is nice. 


I would be in favor of doing explicit relative imports here for imports within `_libs`
Just so I'm clear do you only want those imports to be relative from modules *within* the `tslibs` folder or from any module? For instance if you look at `index.pyx` it currently has:

```python
from pandas._libs.tslibs.conversion cimport maybe_datetimelike_to_i8
```

So do we want this to be `from .tslibs.conversion import maybe_datetimelike_to_i8` or should this stay absolute since it's not in the same directory?

Note that there is a `.util` module in the higher level directory and in tslibs. Full name spacing makes it a little bit clearer which one is being imported so I still slightly prefer that, but if I'm the odd man out on this one certainly glad to change
Side note - I repurposed this PR to just focus on imports for the time being. I think the actual changes to support Python3 syntax make more sense to do in a follow up. I think the `unicode` fused type is going to be finicky so may even wait for that until we officially drop Py2 support soon
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23940?src=pr&el=h1) Report
> Merging [#23940](https://codecov.io/gh/pandas-dev/pandas/pull/23940?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/5b0610b875476a6f3727d7e9bedb90d370c669b5?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##           master   #23940   +/-   ##
=======================================
  Coverage   42.46%   42.46%           
=======================================
  Files         161      161           
  Lines       51557    51557           
=======================================
  Hits        21892    21892           
  Misses      29665    29665
```

| Flag | Coverage Δ | |
|---|---|---|
| #single | `42.46% <ø> (ø)` | :arrow_up: |


------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23940?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/23940?src=pr&el=footer). Last update [5b0610b...4d0437f](https://codecov.io/gh/pandas-dev/pandas/pull/23940?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/23940?src=pr&el=h1) Report
> Merging [#23940](https://codecov.io/gh/pandas-dev/pandas/pull/23940?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/8b4b38fd7995cb59b0595f2d06cb4b984b5886a9?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #23940      +/-   ##
==========================================
+ Coverage    92.3%   92.31%   +<.01%     
==========================================
  Files         163      163              
  Lines       51977    51977              
==========================================
+ Hits        47979    47980       +1     
+ Misses       3998     3997       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.71% <ø> (ø)` | :arrow_up: |
| #single | `42.99% <ø> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23940?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/23940/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `87.84% <0%> (+0.09%)` | :arrow_up: |

------

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

On further thought, I think Joris's suggestion is a really good one.  A lot of effort has gone into making _libs modules, particularly _libs.tslibs self-contained.  Using relative imports make it really obvious that a module has no one-level-up dependencies.
OK back to absolute @jreback PTAL
got lost in the mix, can you merge master.
Hypothesis test failure should be unrelated @jreback PTAL
can you merge master. lgtm. ping on green.
@jreback green
thanks @WillAyd