Reputation: 1189
I am running some calculations in python that are time consuming and I would like to serialize the intermediate results.
My problem is the following: each calculation is configured by multiple parameters: a couple of numbers and strings. Of course, I can concatenate everything, but it will be also extremely long string and I am afraid that it will exceed allowed length of a file name.
Any ideas how to cope with this?
Upvotes: 0
Views: 105
Reputation: 460
An easy way would be to use md5 (e.g. https://docs.python.org/2/library/md5.html)
import md5
tmp=md5.new()
tmp.update(<parameter1>)
...
filename=tmp.hexdigest()
This should generate filenames which are unique enough. You can add the current timestamp as a parameter to raise uniqueness.
Upvotes: 1