-
Notifications
You must be signed in to change notification settings - Fork 590
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
ENH/CLN: Fix DataType hashing #1172
Conversation
d92802d
to
89bcb86
Compare
c9a67d6
to
45f7ec7
Compare
|
@wesm can you review this when you get a chance? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me. Thanks for doing this!
ibis/expr/datatypes.py
Outdated
| self._name = name | ||
| if not isinstance(schema, Schema): | ||
| raise TypeError( | ||
| 'schema argument to HasSchem class must be a Schema instance' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
| @@ -390,78 +415,79 @@ def valid_literal(self, value): | |||
|
|
|||
| class Int8(Integer): | |||
|
|
|||
| __slots__ = () | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do __slots__ inherit in any reasonable way? (I assume not)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right. Stated here: https://docs.python.org/3.6/reference/datamodel.html#notes-on-using-slots
The action of a
__slots__declaration is limited to the class where it is defined. As a result, subclasses will have a__dict__unless they also define__slots__(which must only contain names of any additional slots).
|
Merging on green. |
92ca85b
to
daea4ca
Compare
daea4ca
to
3189e43
Compare
Before this PR, every datatype's hash function was
hash(type(self)), whichmeans collisions galore (triggering eq comparison when using complex types
as dict keys). This PR provides a hash function based on
__slots__givingevery type a unique hash based on
type(self), its slots (if any) + thenullablefield from theDataTypeparent class.