Skip to content

COMPAT: Import abstract classes from collections.abc #22020

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

Closed
holymonson opened this issue Jul 23, 2018 · 6 comments
Closed

COMPAT: Import abstract classes from collections.abc #22020

holymonson opened this issue Jul 23, 2018 · 6 comments
Labels
Compat pandas objects compatability with Numpy or Python functions good first issue
Milestone

Comments

@holymonson
Copy link
Contributor

holymonson commented Jul 23, 2018

Changed in version 3.3: Moved Collections Abstract Base Classes to the collections.abc module. For backwards compatibility, they continue to be visible in this module through Python 3.7. Subsequently, they will be removed entirely.

Numpy team has done it. numpy/numpy#10743

if PY33:
    import collections.abc as collections_abc
else:
    import collections as collections_abc

A problem is collections_abc being too long, isinstance(something, collections_abc.Iterable) occupies half line, but from pandas.compat.collections_abc import Iterable might pollute namespace.


BTW, pandas/compat/__init__.py seems messy. Since Much of the code in this module comes from Benjamin Peterson's six library, why not require six like many other libraries do?

@gfyoung gfyoung added the Compat pandas objects compatability with Numpy or Python functions label Jul 23, 2018
@gfyoung
Copy link
Member

gfyoung commented Jul 23, 2018

@holymonson :

  • The collections_abc proposal seems reasonable.
  • As for six, I imagine it's because we only needed that chunk of code for __init__ and not everything else, though probably someone like @jreback would know more...

@jbrockmendel
Copy link
Member

re six: it is an implicit dependency because dateutil requires it. It would simplify some of the intra-pandas dependencies if we got imports from six instead of pandas.compat.

@holymonson
Copy link
Contributor Author

Since six provide some but not all compat things, keeping all import from pandas.compat seems more unified. What I suggest is from six import what's needed to pandas.compat, that will clean up code in pandas.compat.

@holymonson
Copy link
Contributor Author

holymonson commented Jul 23, 2018

Being the last of the 2.x series, 2.7 will have an extended period of maintenance. Specifically, 2.7 will receive bugfix support until January 1, 2020. All 2.7 development work will cease in 2020.

The End Of Life date of Python 2 is 2020-01-01, let's forget six and clean up the code in the future.

@gfyoung
Copy link
Member

gfyoung commented Jul 23, 2018

@holymonson : I still think your collections proposal is reasonable though. Feel free to do a PR for that.

@TomAugspurger
Copy link
Contributor

We're planning to remove 2.7 support at the end of the year. If somewhat absolutely needs Python 3.8 support before then, they're welcome to update pandas/compat/__init__.py to handle this. Otherwise, I'd recommend waiting until January when we remove Python 2 compatibility code, and we can just update the imports to collections.abc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions good first issue
Projects
None yet
Development

No branches or pull requests

5 participants