[Mastering-perl] Ties, DNA, and and Perl memory
brian d foy
brian.d.foy at gmail.com
Tue Jan 31 17:26:01 EST 2006
Can I save a lot of memory (not speed) by making an array a scalar? I
think I can, but Devel::Size is telling me that I'm not. I don't
really believe Devel::Size, but I don't have the goods to back up my
suspicions. I've posted my adventures with Devel::Size and tied
arrays on Perlmonks:
http://www.perlmonks.org/?node_id=526887
I thought that I'd make an interesting example by creating a strand of
DNA in a single scalar. I'd use three bits per base pair (because two
isn't enough if I want to mark a position as unknown, but that would
certainly make vec() useful). I'd give it a tied interface so it
looked like an array but was really a single long string. I only
incur the scalar overhead once. Or at least that's what I think should
happen.
I like the idea of this example because it dovetails with my
benchmarking chapter in which I talk about the trade-off between
memory and speed, and I have something interesting to measure. I
certainly want to example to work out so that it uses less memory (and
I'm sorta hoping it turns out to be slower too, in a perverse,
good-for-plot-development sort of way)
Now, beyond that, I wonder how real life geneticists and biologists
put all this stuff in memory. The ones I've talked to seem to do a lot
of vanilla text processing, so maybe they have these really long
strings and a lot of RAM. Anyone playing with DNA and Perl? :)
--
brian d foy <brian.d.foy at gmail.com>
http://www.pair.com/~comdog/
More information about the Mastering-perl
mailing list