On 12/11/2013 11:10, Frank-Rene Schäfer wrote:
Admittedly, I have no knowledge about the python implementation.
There is no "the" regarding Python implementations. Cpython alone is at
either 2.7.6 or 3.3.3 with 3.4 at alpha, then there's IronPython,
Jython, PyPy and lots more that I'm sure
On Tue, Nov 12, 2013, at 4:39, Frank-Rene Schäfer wrote:
> > 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.
>
> To the contrary, it means everything about what 'isimmutable'
=?UTF-8?Q?Frank=2DRene_Sch=C3=A4fer?= wrote:
> The ImmutableNester special class type would be a feature to help
> checks to avoid recursion. Objects of classes derived from
> ImmutableNester have no mutable access functions and allow insertion
> of members only at construction time. At construct
On 2013-11-12 11:14, Steven D'Aprano wrote:
On Tue, 12 Nov 2013 18:12:43 +1100, Chris Angelico wrote:
def isimmutable(x):
try:
hash(x)
return True
except TypeError:
return False
I'm afraid that doesn't test for immutability. It tests for hashability,
which
On Tue, 12 Nov 2013 08:01:19 +0100, Frank-Rene Schäfer wrote:
> the existence of a built-in function 'isimmutable' puts the concept of
> immutability some more into the spotlight.
That is an argument against the proposal, not in favour. The concept of
immutability doesn't need to be in the spotl
On Tue, 12 Nov 2013 18:12:43 +1100, Chris Angelico wrote:
> def isimmutable(x):
> try:
> hash(x)
> return True
> except TypeError:
> return False
I'm afraid that doesn't test for immutability. It tests for hashability,
which is different.
No well-behaved mutable
> So how do you figure out whether something's immutable or not? Are you
> going to ask the object itself? If so, stick with __hash__, and just
> follow the rule that mutable objects aren't hashable - which is, if
> I'm not mistaken, how things already are. And if not, then how? How
> will you know
On Tue, Nov 12, 2013 at 8:39 PM, Frank-Rene Schäfer wrote:
>> 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.
>
> To the contrary, it means everything about what 'isimmutable' c
> 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.
To the contrary, it means everything about what 'isimmutable' could
contribute: security against advert or inadvert insertion of
On Tue, Nov 12, 2013 at 8:12 PM, Frank-Rene Schäfer 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 d
(1) hash()-ability != immutability (!)
Proof:
class X:
def __hash__(self): return 0
def pseudo_isimmutable(this):
try:
hash(this)
return True
except TypeError:
return False
shapeshifter = (1, 2, X())
print pseudo_isimmutable(shapeshifter)
shapeshifter[2].chan
On Tue, Nov 12, 2013 at 6:01 PM, Frank-Rene Schäfer wrote:
> 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 func
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
Hi Frank-Rene, and welcome. Comments below.
On Mon, 11 Nov 2013 21:47:45 +0100, Frank-Rene Schäfer wrote:
> I prepared a PEP and was wondering what your thoughts are about it:
>
> PEP:
> Title: ``isimmutable(Obj)`` and/or ``ImmutableNester``
[...]
> * Python-Version: 2.
On Tue, Nov 12, 2013 at 11:17 AM, Steven D'Aprano
wrote:
> On Mon, 11 Nov 2013 12:55:56 -0800, Ned Batchelder wrote:
>
>> On Monday, November 11, 2013 3:47:45 PM UTC-5, Frank-Rene Schäfer wrote:
>>> I prepared a PEP and was wondering what your thoughts are about it:
>>
>> The best place to discuss
On 12/11/2013 00:17, Steven D'Aprano wrote:
On Mon, 11 Nov 2013 12:55:56 -0800, Ned Batchelder wrote:
On Monday, November 11, 2013 3:47:45 PM UTC-5, Frank-Rene Schäfer wrote:
I prepared a PEP and was wondering what your thoughts are about it:
The best place to discuss proposals for changes t
On Mon, 11 Nov 2013 12:55:56 -0800, Ned Batchelder wrote:
> On Monday, November 11, 2013 3:47:45 PM UTC-5, Frank-Rene Schäfer wrote:
>> I prepared a PEP and was wondering what your thoughts are about it:
>
> The best place to discuss proposals for changes to the Python language
> and library is t
> A built-in function 'isimmutable()' shall tell efficiently whether the
> object
> of concern is mutable or not.
What's the benefit over attempting to hash() the object?
copy.deepcopy already has special case for int, string, and tuples
(including tuples that do and do not have mutable members)
On Monday, November 11, 2013 3:47:45 PM UTC-5, Frank-Rene Schäfer wrote:
> I prepared a PEP and was wondering what your thoughts are about it:
The best place to discuss proposals for changes to the Python language and
library is the Python-Ideas mailing list:
https://mail.python.org/mailman/list
I prepared a PEP and was wondering what your thoughts are about it:
PEP:
Title: ``isimmutable(Obj)`` and/or ``ImmutableNester``
Version:
Last-Modified:
Author: Frank-Rene Schaefer, fsch...@users.sourceforge.net
* BDFL-Delegate:
* Discussions-To: f
20 matches
Mail list logo