Robert Klemme
11/20/2007 12:39:00 PM
2007/11/20, mla mla <maurice.aubrey@gmail.com>:
> It seems that when you marshal hashes the binary representations aren't
> stable.
>
> This is an issue with PStore because it uses the md5 of the marshaled
> data to decide whether it's changed and whether a disk write is needed.
>
> Perl's serialization module, Storable, has a $Storable::canonical option
> which, if true, sorts the keys of hashes. Would it be reasonable to add
> such an option to Marshal?
Sounds good to me. What happens if keys are not sortable? Fallback
to default, i.e. store unsorted?
> I read that Ruby 1.9 will have ordered hashes. So maybe that will make
> the issue moot?
Probably not because not all applications need ordered Hashes.
Usually ordering imposes an overhead that you might not want to pay.
So I'd say even in 1.9 this issue is not (fully) gone.
Kind regards
robert
--
use.inject do |as, often| as.you_can - without end