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

Generate model ID based on hash of its parameters #43

Open
ddevault opened this issue Nov 12, 2019 · 4 comments
Open

Generate model ID based on hash of its parameters #43

ddevault opened this issue Nov 12, 2019 · 4 comments

Comments

@ddevault
Copy link

No description provided.

@remiberthoz
Copy link
Contributor

@kerrickstaley and I explain why it would not be wise to do so in #49 (comment). Basically it would mean that one cannot update the model without generating obsolete models in user databases.

@skunne
Copy link

skunne commented Apr 19, 2023

Hello,

Thank you for this awesome and simple library.

Would it be wise for the user to generate a model id and deck id with the hash of a string hardcoded in the program?

I generated 12 decks using the same model of cards. For the model I used id hash(hardcodeddate+hardcodedprojectname+'model') % (1 << 31) and for each deck I used id hash(hardcodeddate+hardcodedprojectname+deckname) % (1 << 31).

This somewhat contradicts your advice to use random numbers, but not too much. Is that OK or is there some counter-argument?

@kerrickstaley
Copy link
Owner

The return value of hash() for a given input changes across runs of your program. So no, that isn’t a good approach because the deck ID will change every time you run the program. You could consider using a SHA256 hash though.

@skunne
Copy link

skunne commented Apr 21, 2023

Thank you for the quick response! I'm using hashlib.sha256 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants