[FEATURE] New Features for frozendict
I would slowly add a bunch of new features for frozendict. See TODO List, fist part: https://github.com/Marco-Sulla/python-frozendict/issues/34
I originally thought to add these features to an experimental type, coold. Currently, coold is undocumented and unused, so I don't think it's much of use to add these features to an obscure type. I think will remove coold.
Possibility to get a value from frozendict values object by index Possibility to get a key from frozendict keys object by index Possibility to get a item from frozendict items object by index
Given that this is a frozendict class rather than a frozenlist class, I'm not sure of the usefulness of these "by index" functions; but of course this is your own project so you're free to add whatever functionality that you like! :slightly_smiling_face:
Looking at https://github.com/Marco-Sulla/python-frozendict#api ...
"set(key, value) It returns a new frozendict. If key is already in the original frozendict, the new one will have it with the new value associated. Otherwise, the new frozendict will contain the new (key, value) item."
If the key is already in fd and fd[key] == value, would it be worth optimising this function to return fd itself unchanged? (e.g. like the setdefault function is documented as doing). Hmmm, although I guess that only works if value itself is an immutable type?
"It returns a the key at" - small typo.
Given that this is a
frozendictclass rather than afrozenlistclass, I'm not sure of the usefulness of these "by index" functions
Well, it was asked in past in Python Ideas for dict, for debugging purposes. Furthermore now dict is ordered, so I feel natural to add the ability to access it also by insertion index. I don't want to add all the Sequence API; only slicing and index. Other methods (delete_by_index, key, value, item, move, insert) also needs the index to act, but they are not part of the Sequence API. Some of them are implemented in OrderedDict.
but of course this is your own project so you're free to add whatever functionality that you like! slightly_smiling_face
I would really like this will be not only "my" project. I removed any personal reference from readme and tests. But I suppose the project is too much small.
set(key, value) [...] If the key is already in
fdandfd[key] == value, would it be worth optimising this function to returnfditself unchanged? (e.g. like the setdefault function is documented as doing). Hmmm, although I guess that only works ifvalueitself is an immutable type?
It's not too much complicated, but I have to think a little about it.
"It returns a the key at" - small typo.
Thank you :)
I would really like this will be not only "my" project.... But I suppose the project is too much small.
The other way of looking at it is that maybe this module already does most of what people need from a frozendict class, and that's why there haven't been many external contributions :slightly_smiling_face:
It's another way to say it's a small project :D
Needing something and being able to contribute to its development are vastly different things.
+1 for deepfreeze, #30, #34.
+1 for deepfreeze
deepfreeze implemented in 2.4.0