PEP 218 Re: ANN: set-0.1 module available

Fernando Pérez fperez528 at yahoo.com
Sat May 18 02:14:32 EDT 2002


James J. Besemer wrote:

>> I beg to differ. Mathematically, there's nothing in the idea of a set that
>> makes it immutable. I know that Python is not a mathematics-only language,
>> but much of the cleanliness of its design does come from following abstract
>> ideas as much as is reasonable. And enforcing immutability on a set is one
>> hell of a breakage for an object as basic to many mathematical ideas as a
>> set is.
> 
> I beg to differ.  Mathematically, there's no notion of assignment like we
> have in
> programming.  From a traditional mathematics view " x = x + 1" is a
> nonsensical
> statement.  At best it's a contradiction in terms.  In Mathematics, you
> don't
> have assignment that can be done over and over.  You can only make
> statements
> about equality or inequality.  At bottom all mathematics is defined in terms
> of sets and predicates about sets.
> In the context of mathematics I would argue that ALL objects are immutable. 

Ok, I should have expressed myself more carefully. I'm not a mathematician by 
training, but thanks to your post I did brush up at least on the starters of 
ZFC set theory. My only formal contact with the subject had been in long ago 
history of mathematics courses I took for fun.

Your points about immutability in mathematics are perfectly valid in the sense 
that time is not a mathematical concept, therefore objects have the value 
given at the time of their definition. When you say 

A = {X | X is not a member of X}

A has been defined and you are done.  Any later additions to the set will 
involve a redefinition.

What I had in mind is that in the context of an evolving problem (such as is a 
computer program which executes in time), the elements which satisfy the 
definition of a given set can increase. What I had in mind was the difference 
between saying 'x=5', which fairly well 'fixes' x and saying 

's={f | f is a file in '.' with size > 10k} '

which can change if new files are added to the directory as the program 
evolves (assuming it checks periodically). So while I agree with your strict 
mathematical definition of immutability, I hope what I had in mind is clearer 
now. Shame on me for the lack of precision, I'll be more careful next time.


>> In my mind, that's like saying that you add integers to a language but you
>> can't
>> do arithmetic with them ;)
> 
> I beg to differ.  ;o)
> 
> Fact of the matter, integers, strings and longs presently ARE immutable and
> you
> still CAN do arbitrary arithmetic with them.  E.g.,

Here you completely misunderstood me. I'm perfectly aware of how strings and 
ints work in Python, I was simply using my sentence as an analogy of a 
_hypothetical_ situation of 'useless integers' to express why I consider 
immutable sets to be of limited usability. Read it again, I said 'add 
integers to _a_ language', I was not talking about Python at all. For the 
record yes, I have tried adding two numbers in python and seen it work.

Cheers,

f.



More information about the Python-list mailing list