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


Groups > comp.lang.python > #59158

Re: 'isimmutable' and 'ImmutableNester'

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!news.astraweb.com!border2.a.newsrouter.astraweb.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <fschaef@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'tree': 0.05; 'lines,': 0.07; 'puts': 0.07; "subject:' ": 0.07; 'immutable': 0.09; 'insertion': 0.09; 'cc:addr:python-list': 0.11; 'immutability': 0.16; 'mutable': 0.16; 'objects.': 0.16; 'tuple': 0.16; 'prevent': 0.16; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'define': 0.26; 'first,': 0.26; 'somewhere': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message- id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; 'existence': 0.31; 'second,': 0.31; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'members.': 0.37; 'implement': 0.38; 'does': 0.39; 'either': 0.39; 'how': 0.40; 'from:charset:utf-8': 0.61; 'personal': 0.63; 'soon': 0.63; 'become': 0.64; 'more': 0.64; 'obvious': 0.74
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=0kQOBR2HowqscoiCKoyfZFFVp+2VNn6vetzcOHTI76I=; b=OlEx0GnRo74S6ESoTW+5IprZ1Ws6nC+2k5n+4j1Ew3S6nM6/eA8yFXMjWrvJluLvSE /cMEIDChzMYQss7PkGqRe/X8nQTKqeDzoFBhO0NoGDsiGQDn0pC13ruc/xab4SIJkStr QujhrQeG1nIpfIKOuQlDZ63KUkEbaBOExGiS2DtkKgSiCD9sWm0zgR6DfUy/l120Ip5l DBCuAEWcjjnxVMCDGvO3DSqDjwB3zmqfU+BZI7Uj8RY4w2gWiV0t+aqH2G/AVTJd/5cW JHaT/4LtPvXDlILu6Ng2ww/EJMjB+cl5bXbNpVHcAhMh1eYkWsMBlYZBmnrBMkM7UvDW pZSw==
MIME-Version 1.0
X-Received by 10.49.105.67 with SMTP id gk3mr34471360qeb.3.1384239680027; Mon, 11 Nov 2013 23:01:20 -0800 (PST)
In-Reply-To <1384206048.30461.46091021.634F0FCA@webmail.messagingengine.com>
References <CAB6+5b_w+kBT=EDqd9wRO80am+Wp2DgrEqSpVEPWkcTAVmYQtQ@mail.gmail.com> <1384206048.30461.46091021.634F0FCA@webmail.messagingengine.com>
Date Tue, 12 Nov 2013 08:01:19 +0100
Subject Re: 'isimmutable' and 'ImmutableNester'
From Frank-Rene Schäfer <fschaef@gmail.com>
To random832@fastmail.us
Content-Type text/plain; charset=UTF-8
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2429.1384239683.18130.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1384239683 news.xs4all.nl 15922 [2001:888:2000:d::a6]:57980
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:59158

Show key headers only | View raw


A tuple is immutable but it may contain mutable objects. In larger
hierarchies of objects it may become less obvious whether down
the lines, there is some mutable object somewhere in the data tree.

One can define a recursive function to check for immutability
manually. However first, it may not be as efficient as if it was
built-in. Second, the existence of a built-in function 'isimmutable'
puts the concept of immutability some more into the spotlight.

You might indeed implement some personal 'policy for copy/deepcopy'.
But, how can you prevent the insertion of an object into the data
tree which does not follow your copy/deepcopy convention? As soon
as you allow members of type 'tuple' you must either check recursively
or only allow ints and strings as tuple members.

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


Thread

Re: 'isimmutable' and 'ImmutableNester' Frank-Rene Schäfer <fschaef@gmail.com> - 2013-11-12 08:01 +0100
  Re: 'isimmutable' and 'ImmutableNester' Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-12 11:33 +0000

csiph-web