News for hackers. Stuff that matters.
Re:Guido on Python by bitL on Friday July 31, 2015 @08:53AM (#9981384)
Imagine immutable dict. How many programs in Python you know would still work?
Re:Guido on Python by mynegation on Friday July 31, 2015 @09:09AM (#9981464)
"Immutable" data structures is rather confusing name. Here it is a synonym for persistent data structure [1], which means that you operate on data structures by creating new "versions" of them, which share a lot of memory with the old versions. Parts of the program that refer to the old version see it as immutable.

[1] https://en.wikipedia.org/wiki/Persistent_data_structure

Re:Guido on Python by tikhonj on Friday July 31, 2015 @02:05PM (#9983282)
Modern radix trees[1] can be as fast as the hash maps you'd find in a language's standard library while providing additional capabilities (ie fast ordered traversal). Making them immutable and persistent[2] is easy and only adds a bit of performance overhead.

Obviously programs that rely on communicating by mutating parts of a dictionary would have to be rewritten to use an immutable, persistent map—but they could still maintain similar performance.

[1]: Namely "adaptive radix trees" as described in “The adaptive radix tree: Artful indexing for main-memory databases” by V. Leis, A. Kemper, and T. Neumann <http://www3.informatik.tu-muenchen.de/~leis/papers/ART.pdf>

[2]: A persistent adaptive radix tree in Java: https://github.com/ankurdave/part

Re:Guido on Python by bitL on Friday July 31, 2015 @02:37PM (#9983473)
Thanks for the radix tree reference!

On the other hand, stating "they could still maintain similar performance" for immutable dictionaries is misleading at best (you are right for dictionary sizes approaching 0). Anyone can look up benchmarks on the Internet showing real-world performance of immutable data structures and make their mind up if they actually can deliver in their particular use cases.

Mutability could be always used to boost performance on Von Neumann architecture if you know what you are doing. It's just becoming impractical due to increased complexity, pervasive security paranoia and the fact that there are very few people that can get things done right. If you want to contribute to advance your case, please create a competing computer architecture as fast as Von Neumann's, physically possible, but based on immutability.

Re:Guido on Python by semi-extrinsic on Friday July 31, 2015 @04:02PM (#9984051)
> Mutability could be always used to boost performance (...)

For the extreme case, see the EQUIVALENCE statement in old Fortran.

Re:Guido on Python by wyldfire on Friday July 31, 2015 @12:29PM (#9982675)
Well, opt-in immutable dict would be awesome. I've found that many times my usage of set and list is more appropriate as their immutable counterparts (frozenset, tuple). Lots of times I create sets or lists with the intention that they be immutable and it would be clearer if I could specify to future me/maintainers/extenders that this should remain as initialized.
Re:Guido on Python by bitL on Friday July 31, 2015 @01:46PM (#9983134)
Re:Guido on Python by bpicolo on Friday July 31, 2015 @11:23PM (#9985781)
Switch to namedtuples for lightweight data structures. No regrets.