Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] New Features for frozendict #52

Open
Marco-Sulla opened this issue Mar 26, 2022 · 6 comments
Open

[FEATURE] New Features for frozendict #52

Marco-Sulla opened this issue Mar 26, 2022 · 6 comments
Labels
Type: Enhancement New feature or request

Comments

@Marco-Sulla
Copy link
Owner

Marco-Sulla commented Mar 26, 2022

I would slowly add a bunch of new features for frozendict. See TODO List, fist part: #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.

@Marco-Sulla Marco-Sulla added the Type: Enhancement New feature or request label Mar 26, 2022
@Marco-Sulla Marco-Sulla pinned this issue Mar 26, 2022
@lurch
Copy link
Contributor

lurch commented Apr 4, 2022

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! 🙂


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.

@Marco-Sulla
Copy link
Owner Author

Given that this is a frozendict class rather than a frozenlist class, 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 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's not too much complicated, but I have to think a little about it.

"It returns a the key at" - small typo.

Thank you :)

@lurch
Copy link
Contributor

lurch commented Apr 5, 2022

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 🙂

@Marco-Sulla
Copy link
Owner Author

It's another way to say it's a small project :D

@davaya
Copy link

davaya commented Dec 15, 2022

Needing something and being able to contribute to its development are vastly different things.

+1 for deepfreeze, #30, #34.

@Marco-Sulla
Copy link
Owner Author

+1 for deepfreeze

deepfreeze implemented in 2.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants