3 ms·
Lots of easy handling of structures immutably. Which Python has a good bit of for sure, with comprehension especially. But I could use more. :) I wish everythi
by Waterluvian 9y ago
Lots of easy handling of structures immutably. Which Python has a good bit of for sure, with comprehension especially. But I could use more. :)
I wish everything immutablejs gave me was built in to Python. :)
- xapata 9y agoComparing with immutablejs, there are 4 broad categories that match: lists, dicts, sets, and iterators. Tuple slicing and concatenation gives you the "immutable" behavior for ordered data. For sets and dicts, one could create a subclass that override add/insert/set methods to return a modified copy. Iterators already have excellent support. I'm not an immutablejs user, but my first skim of the docs doesn't make it clear what's missing from Python. If the immutable subclasses would be valuable, I'll gladly make a module for it. There's already frozenset. A frozendict didn't seem as useful (according to core devs).
- xapata 9y agoPlus, I forgot that sets have nice operators for union, intersection, etc. So you don't need to override anything there.