Why not Ruby?
Fri Jan 2 04:51:53 CET 2009
Marek Kubica <marek at xivilization.net> writes:
> > I guess if it is functional then every mutation must copy and return a
> > new data structure?
> > (Which will be much more efficient in Haskell than
> > in Python - Haskell can share most of the underlying data whereas Python
> > would have to create a new dict every time. At least it only stores
> > references.)
The structure sharing is essential, but you can do it in Python, just
not using Python dicts as far as I can tell.
> Who says that it must create a whole new one? I could imagine that with a
> bit weakref code and some thought an immutable dictionary that shares
> data would be possible in Python too.
I don't see a way to do that. Suppose d and e are dicts that are supposed
to share structure except d['name']='bob' and e['name']='joe'. How do
Functional dictionaries are usually implemented using red-black trees
or AVL trees or similar data structures, rather than hash tables.
More information about the Python-list