On Wed, Oct 2, 2019 at 8:51 AM Greg Ewing <greg.ew...@canterbury.ac.nz> wrote:
>
> Chris Angelico wrote:
> > The question then would be: why is object() not hashable?
>
> It's not hashable because it's supposed to be the ultimate
> base type for all other objects, and not every object is
> hashable.
>
> It only seems odd if you're used to the idea that you get
> a bunch of default behaviours from object, including
> hashability. But if you want strict subtyping and also
> an ultimate base type, the base type has to include very
> little behaviour.
>

Should the default object be comparable? Or would there be a
"Comparable" subtype? If object() can be compared for equality with
another object(), then it'd be illogical to make it unhashable -
there's no reason to deny hashing. If it can't be compared, why not?
Why should the base type include THAT little behaviour?

Python's base object has a lot of extremely useful functionality,
including being able to generate a string representation, introspect
its attributes, pickle and unpickle it, and more. All of these
features are available to all objects unless they choose not to. Do we
really need separate subclasses for Picklable and Hashable, forcing
every class author subclass all of them? Or can we allow most objects
to be indeed pickled and hashed, and then open files choose to be
unpickleable and lists choose to be unhashable?

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/RT2I2KNMXJUE46UGNXD4F4XZVYSWZPLC/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to