From: "Shot (Piotr Szotkowski)" Date: 2008-02-22T02:40:48+09:00 Subject: Re: Object#freeze as a basis for caching of method results? --B5t8AZ5AOUxuGP3g Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Shot (Piotr Szotkowski): > Robert Klemme: >> Now, whether you use the String or demarshal probably mainly depends >> on memory usage. If the String is short enough that approach is >> certainly preferable because it incurs less processing overhead >> (demarshaling). > Ok, I=E2=80=99m totally lost here. I don=E2=80=99t see any demarshalling = happening, > just marshalling (and using that as a key)=E2=80=A6 What am I missing? Ok, I got it now (stupid me) =E2=80=93 you discuss keing the cache with Marshal.dump(self) as opposed to keying it with Marshal.load(Marshal.dump(self)), right? Are marshalled objects in general much bigger (memory-wise) than the =E2=80=98originals=E2=80=99? Also, I usually define dup as Marshal.load(Marshal.dump(self)) =E2=80=93 provided it=E2=80=99s not a bottleneck, does this approach has an= y vices? Lastly, assuming I have a working #dup (Marshal-based or otherwise), wouldn=E2=80=99t dup.freeze be a better/more elegant key than dump+load? Do= es it has any vices? -- Shot --=20 Also, I think there is a typo in the opening. Where you say "Ruby is slow", I think what you mean is "Ruby is an extremely powerful and flexible language". It's an understandable mistake, all of the keys are so close to each other. -- GD, ruby-talk --B5t8AZ5AOUxuGP3g Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQFHvbFBi/mCfdEo8UoRAtd0AJ9HlSv6adQPUi3J9npT/PSjRMjAxACfU0fj nSq+H7g5f6NFzbERvEsRKpA= =LjzJ -----END PGP SIGNATURE----- --B5t8AZ5AOUxuGP3g--