perlquestion
BioLion
<p>Hello Monks,</p>
<p>I wanted to get your opinions before committing to anything, so here goes:</p>
<p>Having read around ([Burned by Storable], [id://762166], [id://711416], [http://en.wikipedia.org/wiki/Serialization#Perl|Serializing data] ,[cpan://Data::Serialize], [cpan://Data::Dumper], [cpan://YAML], ), I am a bit put off by the frequency of people having bad times with Storable. </br>Especially with serializing code refs and the need to use [cpan://Safe] compartments for inflating code refs.</p><p><b>So my question is this - what is the (IYHO) currently preferred method for (recursively) storing objects?</b></p><p>By way of warning, I want to apply this method to a very large object that is a container for ~50-100,000 smaller objects/code refs, that in turn may contain further objects... Much calculation goes into building it up, and i would like to able to cache it at key stages, so that in future i can choose whether to bypass building it from scratch each time.</p><p>Thus, if i could also test for the existence of a stored object at each checkpoint too that would be a huge bonus for me:</p>
<code>if ( store_exists('store_file') ){
...inflate it...
}
else {
...make the object from scratch...
}
</code>
<p>Thanks in advance,</p>
<p><b>Update</b> edited my ramble a bit</p>
<p><b>Update 2 (16 July 09)</b>After much helpful discussion (esp. [clinton]/[ELISHEVA] on the CB, and the posts below), i came to the realisation that storing code refs and objects, while possible, doesn't make sense in my situation because the testing post-inflation ( [id://779859] ) would take more or less as much time as i could save by having 'storage checkpoints' during the build-up of my mecha-objects, and moreover loses me/users much flexibility (i.e. what if they have multiple DB/flat files that they want to work from).</p>
<p>So in the end I decided ( thanks [perrin]! )that it would make more sense to put that time into making my code more efficient, so that users don't need to go for a coffee while their computer thinks...</p>
<p>My codebase is fairly large / diverse, but it has all been handled wonderfully by [mod://Devel::NYTProf], which seems to be the profiler-du-jour round here ( [id://753540] ). There was also much useful info found [id://633699|here]. I particularly found the nytprofhtml utility very useful and nice to work with, especially the way it gives you your code right next to how it is being used, and your can very easily click-navigate right across any code that was called! I set it up with these options:</br><code>export NYTPROF=trace=2:start=begin:file=/tmp/nytprof.out:addpid=1:savesrc=1</code></br></p><p>
So, just a big thanks all round!
</p>
<div class="pmsig"><div class="pmsig-656648">
<i>Just a something something...</i>
</div></div>