-
Notifications
You must be signed in to change notification settings - Fork 22
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
Should Field objects include their owning interface
in equality/hashing?
#40
Comments
I haven't given it any deep thoughts, but the current behavior seems reasonable to me. |
I'll clarify that the possible motivation for this change comes from this comment, based on the old behaviour of
|
I think we should stick as close as possible to the old behaviour (pre Python 3) of |
One way of looking at it is that including the interface in hashing is closer to what zope.schema used to do: hashing was identity based, so >>> d = {}
>>> d[IOne['one']] = 'one'
>>> d[ITwo['two']] = 'two'
>>> d
{<zope.schema._bootstrapfields.Int at 0x10fe64ed0>: 'one',
<zope.schema._bootstrapfields.Int at 0x10ffdb610>: 'two'} Now it cannot: >>> d = {}
>>> d[IOne['one']] = 'one'
>>> d[ITwo['two']] = 'two'
>>> d
{<zope.schema._bootstrapfields.Int at 0x10bc25d90>: 'two'} Including the interface in equality and hashing would restore the ability to have both fields in a dict, while staying true to the language spec. |
+1 to include the interface in the |
Currently they don't include that, leaving open the possibility that two different Field objects from two different interfaces are equal, which may or may not be the intent.
The text was updated successfully, but these errors were encountered: