-
Notifications
You must be signed in to change notification settings - Fork 23
Recursive freeze and unfreeze functions #20
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
base: master
Are you sure you want to change the base?
Conversation
355bd2a
to
f0fd9d4
Compare
31dfa3b
to
f361fd1
Compare
Not sure what to do about generators; i.e. should |
What is the use case for those functions? |
It's a uniform way to create completely immutable complex data structures ( In Python, personally I am using them while working on an application that uses Pydux, with these utility functions I can easily define a complex immutable structure using the more compact Python native notation and unfreeze and refreeze it if I need to make a lot of edits. |
Hopping in; even though I like the idea since it does seem very nice mathematically (like an inverse function), I have to strongly disagree with putting this in the TLDR: This functionality deserves its own library. Perhaps call it |
@kasbah Have you ever released this as |
No, not yet. I am still using them in my own project though. Feel free to copy them from here and use under the MIT license. |
Nice. You could also add support for set -> frozenset. |
Theses are two symmetrical functions to make entire structures immutable and mutable respectively. Converting
dict
andOrderedDict
will behave as expected. All lists are turned into tuples and vice versa.I have based on #15 to integrate with the testing. If this is of interest I will consider adding hypothesis tests to show that
freeze(unfreeze(x)) == x
andunfreeze(freeze(x)) == x
hold true given completely frozen or unfrozen data structures respectively.