From: Austin Ziegler Date: 2005-09-06T11:28:03+09:00 Subject: Efficient Object Reconstruction? I have a problem, and it's been bugging me for a while, so I thought that I'd ask people that know a lot more about the internals of Ruby than I do. In PDF::Writer, I have a complex object graph. Its complexity is mostly caused by the fact that all objects must know their parent object. Maybe something like: foo#35 bar#36 (@parent = foo#35, ...) baz#37 (@parent = foo#35, ...) When this graph gets roundtripped through Marshal, I might have: foo#38 bar#39 (@parent = foo#35, ...) baz#40 (@parent = foo#35, ...) This means that there are now "odd" copies of at least the parent (foo#35) around. This is something that *does* happen when Transaction::Simple is called. Now, if I then add something else: foo#38 bar#39 (@parent = foo#35, ...) baz#40 (@parent = foo#35, ...) bom#41 (@parent = foo#38, ...) Obviously, this not only gets silly after a while, but it gets pretty inefficient. I want to fix Transaction::Simple so that the object graph is *properly* reconstructed. That is, if I Marshal.dump the foo with object ID 35, I don't mind if it's reconstituted as #38, but I want "old" references to #35 reconstructed as references to #38. How can I do that? Preferably, how can I do that without crawling the object graph -- which would be extremely inefficient? -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca