Skip to content

CLN: clean Index._id #37087

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 4 commits into from
Oct 14, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use typing.NewType
  • Loading branch information
topper-123 committed Oct 13, 2020
commit f49c97e82b57fd1d14a5de4e719251f2a9aa81fb
9 changes: 4 additions & 5 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
FrozenSet,
Hashable,
List,
NewType,
Optional,
Sequence,
Tuple,
Expand Down Expand Up @@ -141,8 +142,7 @@ def index_arithmetic_method(self, other):
_o_dtype = np.dtype(object)


class _Identity:
pass
_Identity = NewType("_Identity", object)


def _new_Index(cls, d):
Expand Down Expand Up @@ -562,14 +562,13 @@ def is_(self, other) -> bool:
--------
Index.identical : Works like ``Index.is_`` but also checks metadata.
"""
# use something other than None to be clearer
return self._id is getattr(other, "_id", Ellipsis) and self._id is not None
return self._id is getattr(other, "_id", None)

def _reset_identity(self) -> None:
"""
Initializes or resets ``_id`` attribute with new object.
"""
self._id = _Identity()
self._id = _Identity(object())

def _cleanup(self):
self._engine.clear_mapping()
Expand Down