On 4/29/2012 3:57 AM, John O'Hagan wrote:
How do function objects fit into this scheme? They have __hash__, __eq__, seem
to work as dict keys and are mutable. Is it because their hash value doesn't
change?
I suspect functions use the default equality and hash based on id, which
does not chang
On Sat, 28 Apr 2012 11:35:12 -0700
Chris Rebert wrote:
[...]
> Correct. Pedantically, you can define __hash__() on mutable objects;
> it's just not very useful or sensible, so people generally don't. As
> http://docs.python.org/reference/datamodel.html#object.__hash__ states
> [emphasis added]:
>
(sent from my phone)
On Apr 28, 2012 7:36 PM, "Chris Rebert" wrote:
> Correct. Pedantically, you can define __hash__() on mutable objects;
> it's just not very useful or sensible, so people generally don't.
I find it's fine to define __hash__ on mutable objects as long as __eq__
only relies on im
On 4/28/2012 2:09 PM, laymanzh...@gmail.com wrote:
In my understanding, there is no directly relation between mutable
and hashable in Python. Any class with __hash__ function is
"hashable".
According the wiki: http://en.wikipedia.org/wiki/Immutable_object
In object-oriented and functional prog
On 28/04/2012 23:30, Temia Eszteri wrote:
Yes, you're right. Being mutable and hashable are orthogonal properties.
The implication
mutable => non hashable
is just a design choice.
The reason for such a choice is the following. If a key-element pair K:X
is added to a container C and then K
>Yes, you're right. Being mutable and hashable are orthogonal properties.
>The implication
> mutable => non hashable
>is just a design choice.
>
>The reason for such a choice is the following. If a key-element pair K:X
>is added to a container C and then K is changed by some external Python
>
On 4/28/2012 20:09, laymanzh...@gmail.com wrote:
I'm just learning Python. The python doc about mutable and hashable is
confusing to me.
In my understanding, there is no directly relation between mutable and hashable in
Python. Any class with __hash__ function is "hashable".
According the wik
On Sat, Apr 28, 2012 at 11:09 AM, wrote:
> I'm just learning Python. The python doc about mutable and hashable is
> confusing to me.
>
> In my understanding, there is no directly relation between mutable and
> hashable in Python. Any class with __hash__ function is "hashable".
>
> According the
laymanzh...@gmail.com wrote:
> I'm just learning Python. The python doc about mutable and hashable is
> confusing to me.
>
> In my understanding, there is no directly relation between mutable and
> hashable in Python. Any class with __hash__ function is "hashable".
>
> According the wiki: http:/
I'm just learning Python. The python doc about mutable and hashable is
confusing to me.
In my understanding, there is no directly relation between mutable and hashable
in Python. Any class with __hash__ function is "hashable".
According the wiki: http://en.wikipedia.org/wiki/Immutable_object
10 matches
Mail list logo