Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You could theoretically log and replay all manipulations to a mutable Python object to achieve it's state prior to the misguided mutation. But that's painful and expensive. So is mapping logged events to inverse functions in such a way that a mutation can be reverted.</p> <p>The trend with functional programming, however seems to strongly encourage expanded use of immutable data...<em>especially with concurrent programming</em>. This mindset isn't just limited to functional languages like Haskell, OCaml, and Erlang. It's even <a href="http://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html" rel="nofollow">infiltrated the Java world</a>:</p> <blockquote> <p>An object is considered immutable if its state cannot change after it is constructed. Maximum reliance on immutable objects is widely accepted as a sound strategy for creating simple, reliable code.</p> <p>Immutable objects are particularly useful in concurrent applications. Since they cannot change state, they cannot be corrupted by thread interference or observed in an inconsistent state.</p> <p>Programmers are often reluctant to employ immutable objects, because they worry about the cost of creating a new object as opposed to updating an object in place. The impact of object creation is often overestimated, and can be offset by some of the efficiencies associated with immutable objects. These include decreased overhead due to garbage collection, and the elimination of code needed to protect mutable objects from corruption.</p> <p>The following subsections take a class whose instances are mutable and derives a class with immutable instances from it. In so doing, they give general rules for this kind of conversion and demonstrate some of the advantages of immutable objects.</p> </blockquote> <p>Generate a new list with a map or list comprehension and modify accordingly. If Ram really is an issue, consider using a <a href="http://docs.python.org/tutorial/classes.html#generators" rel="nofollow">generator</a> with that gives you an iterable with desired modification and a lower memory footprint. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload