A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-February/042583.html below:

[Python-Dev] bool does not want to be subclassed?

[Python-Dev] bool does not want to be subclassed? [Python-Dev] bool does not want to be subclassed?François Pinard pinard at iro.umontreal.ca
Mon Feb 16 15:15:16 EST 2004
[Martin von Löwis]
> A mutable type is one whose instances have state that can change over
> the life of the object. [...]

Interesting presentation.  The following detail is worth stressing:

>   equal objects should hash equal.

This should be stressed as a formal requirement for a correctly behaved
hashing function.  The other formal requirement being that a hash
function should always compute the same value for the lifespan of an
object, and that value should be a non-negative integer (not a long
one?).  A _desirable_ property, but not a requirement, is that two
unequal objects yield different hashes.

So, instead of explaining how we should cleverly use `__hash__' to
describe immutability, we might describe what `__hash__' ought to
be, and then merely notice that hashable objects could be useful to
represent immutable objects (whether user objects or builtin objects).

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4