LucaCappelletti94 / dict_hash

Python package to hash dictionaries using default hash, md5, sha256 and more.
MIT License
24 stars 2 forks source link

Python datetime & date fields support #4

Closed vlaskinvlad closed 3 years ago

vlaskinvlad commented 3 years ago

I was trying to use the library, but endned up scripting my own because of the absense of the datetimefields support out of the box.

Something like that might do:

if isinstance(value, (date, datetime)): 
    value_to_use = value.isoformat()
LucaCappelletti94 commented 3 years ago

On it!

LucaCappelletti94 commented 3 years ago

Can you think of other objects that were not currently covered? May I ask what is your use case? We use the library mostly for cache-related stuff here: https://github.com/zommiommy/cache_decorator

Matthias1590 commented 3 years ago

I created a pull request that covers datetime objects #5

LucaCappelletti94 commented 3 years ago

Looking into it, thanks @Matthias1590 !

LucaCappelletti94 commented 3 years ago

I have published the new version on Pypi. Do let me know if it works fine for you guys!

Matthias1590 commented 3 years ago

Works for me! Including datetime.datetime is not necessary though.

LucaCappelletti94 commented 3 years ago

I'll remove it, you are right.