-
Notifications
You must be signed in to change notification settings - Fork 114
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
feat: Allow compatibility with other ShortUUID libraries (#104) #107
Conversation
This is getting the causality wrong, as this is the original ShortUUID library, which means that the other libraries aren't compatible with this one. I'm not sure whether this library needs to change because someone copied it and made it incompatible, but maybe it won't hurt to be practical. I'll review the PR now and see, thank you for the contribution! |
This looks ok, I guess it can't hurt anything. However, could you rename the argument to Thanks again! |
Thanks for the response, I'll get at it shortly. |
Just finished the requested changes! |
Looks good, thank you! Do you know whether libraries with repeated characters work? They should, since you're using a dict, but I just want to make sure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, thank you!
Sorry, I didn't quite understand your question. You meant to ask if libraries with non-unique characters in the alphabet would work? Since dictionaries preserve insertion order, but can't have duplicated keys, I used it to eliminate duplicates while maintaining the original order of the characters in the alphabet string. I mainly use this library when working with shortUUIDs, so I don't really have a grasp of other libraries. Maybe the issue's OP could answer that. |
I was asking if character deduplication works as required or if, for example, it leaves the last character it sees, so |
Understood. It stores the first appearance of the character. Using your example: >>> string = "1a1"
>>> list(dict.fromkeys(string))
['1', 'a'] and >>> string = "a1a1"
>>> list(dict.fromkeys(string))
['a', '1'] |
Excellent, thank you! |
My attempt to fix: #104.
I've added
should_sort
kwarg to set_alphabet, whenever this is set toFalse
, the code will use an ordered set rather than the default behaviour of sorting an unordered set.Other than that, I've tried to integrate this behaviour into the Django Field. I don't have any experience working with custom Django fields, so I'd appreciate if someone could review commit 077ed4.