Re: Immutability and Python

Discussion in 'Python' started by andrea crotti, Oct 29, 2012.

  1. 2012/10/29 Jean-Michel Pichavant <>:
    >
    > "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..
     
    andrea crotti, Oct 29, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. andrea crotti

    Immutability and Python

    andrea crotti, Oct 29, 2012, in forum: Python
    Replies:
    8
    Views:
    231
    Thomas Rachel
    Nov 8, 2012
  2. andrea crotti

    Re: Immutability and Python

    andrea crotti, Oct 29, 2012, in forum: Python
    Replies:
    0
    Views:
    179
    andrea crotti
    Oct 29, 2012
  3. Mark Lawrence

    Re: Immutability and Python

    Mark Lawrence, Oct 29, 2012, in forum: Python
    Replies:
    0
    Views:
    188
    Mark Lawrence
    Oct 29, 2012
  4. Paul Rubin

    Re: Immutability and Python

    Paul Rubin, Oct 29, 2012, in forum: Python
    Replies:
    7
    Views:
    170
    Steven D'Aprano
    Oct 29, 2012
  5. Terry Reedy

    Re: Immutability and Python

    Terry Reedy, Oct 29, 2012, in forum: Python
    Replies:
    0
    Views:
    179
    Terry Reedy
    Oct 29, 2012
Loading...

Share This Page