Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #59168

Re: 'isimmutable' and 'ImmutableNester'

References <CAB6+5b_w+kBT=EDqd9wRO80am+Wp2DgrEqSpVEPWkcTAVmYQtQ@mail.gmail.com> <1384206048.30461.46091021.634F0FCA@webmail.messagingengine.com> <CAB6+5b_-S2=hUKosR7ANUP15SadtvtY5fEr4Y85f3sBBLHfFWA@mail.gmail.com>
Date 2013-11-12 20:21 +1100
Subject Re: 'isimmutable' and 'ImmutableNester'
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2441.1384248069.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Nov 12, 2013 at 8:12 PM, Frank-Rene Schäfer <fschaef@gmail.com> wrote:
> (1) hash()-ability != immutability (!)
>
> Proof:
>
> class X:
>     def __hash__(self): return 0
>

x == y != y == x

Proof:

class X:
   def __eq__(self,other): return True
class Y:
   def __eq__(self,other): return False

All you've done is proven that you can subvert things. By fiddling
with __hash__, __eq__, and so on, you can make sets and dicts behave
very oddly. Means nothing.

Fundamentally, your mutability check is going to need some form of
assistance from user-defined classes. That means a class can break
your rules.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: 'isimmutable' and 'ImmutableNester' Chris Angelico <rosuav@gmail.com> - 2013-11-12 20:21 +1100

csiph-web