B
Brian Buckley
------=_Part_5824_14803554.1139341077696
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Hello,
When one marshals a constant and later unmarshals it, a brand new object
appears to be created during unmarshalling. This seems wasteful, especiall=
y
in cases when constants are large (contain many attributes). Is it possibl=
e
to customize marshal for a class (or for singleton objects of the class) so
that unmarshalling a constant simply returns the already existing constant
rather than creating a new one? I've noticed Fixnum's exhibit this
behavior.
--Brian
class A;
A1 =3D A.new
end
before =3D A::A1
after =3D Marshal.load(Marshal.dump(before)) #marshal and back
puts before =3D=3D after #darn -- it is false
puts before.object_id =3D=3D after.object_id #same here
# it works for Fixnums
before =3D 123
after =3D Marshal.load(Marshal.dump(before))
puts before =3D=3D after # true
puts before.object_id =3D=3D after.object_id #also true
------=_Part_5824_14803554.1139341077696--
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Hello,
When one marshals a constant and later unmarshals it, a brand new object
appears to be created during unmarshalling. This seems wasteful, especiall=
y
in cases when constants are large (contain many attributes). Is it possibl=
e
to customize marshal for a class (or for singleton objects of the class) so
that unmarshalling a constant simply returns the already existing constant
rather than creating a new one? I've noticed Fixnum's exhibit this
behavior.
--Brian
class A;
A1 =3D A.new
end
before =3D A::A1
after =3D Marshal.load(Marshal.dump(before)) #marshal and back
puts before =3D=3D after #darn -- it is false
puts before.object_id =3D=3D after.object_id #same here
# it works for Fixnums
before =3D 123
after =3D Marshal.load(Marshal.dump(before))
puts before =3D=3D after # true
puts before.object_id =3D=3D after.object_id #also true
------=_Part_5824_14803554.1139341077696--