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


Groups > comp.lang.python > #32389 > unrolled thread

Re: Immutability and Python

Started byJean-Michel Pichavant <jeanmichel@sequans.com>
First post2012-10-29 17:00 +0100
Last post2012-10-29 17:00 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Re: Immutability and Python Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-10-29 17:00 +0100

#32389 — Re: Immutability and Python

FromJean-Michel Pichavant <jeanmichel@sequans.com>
Date2012-10-29 17:00 +0100
SubjectRe: Immutability and Python
Message-ID<mailman.3023.1351526408.27098.python-list@python.org>

----- Original Message -----
> 2012/10/29 Jean-Michel Pichavant <jeanmichel@sequans.com>:
> >
> > "return NumWrapper(self.number + 1) "
> >
> > still returns a(nother) mutable object.
> >
> > So what's the point of all this ?
> >
> > JM
> >
> 
> Well sure but it doesn't modify the first object, just creates a new
> one.  There are in general good reasons to do that, for example I can
> then compose things nicely:
> 
> num.increment().increment()
> 
> or I can parallelize operations safely not caring about the order of
> operations.
> 
> But while I do this all the time with more functional languages, I
> don't tend to do exactly the same in Python, because I have the
> impression that is not worth, but maybe I'm wrong..
> 

In an OOP language num.increment() is expected to modify the object in place.
So I think you're right when you say that functional languages technics do not necessarily apply to Python, because they don't.

I would add that what you're trying to suggest in the first post was not really about immutability, immutable objects in python are ... well immutable, they can be used as a dict key for instance, your NumWrapper object cannot.


JM



-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web