The stupid question is the question not asked | |
PerlMonks |
Re: Perl object memory overheadby BrowserUk (Patriarch) |
on Mar 28, 2014 at 02:00 UTC ( [id://1080032]=note: print w/replies, xml ) | Need Help?? |
If you have 3 million hashes, then you need to be able to refer to them, so, you've probably got them, or rather, references to them, stored in an Array (an @AoH):
To turn a hashref into an object, you need to bless it. The effect on memory is:
Zilch! However, then you need to manipulate the contents of those 'objects'. Manipulate those 3e6 objects via the inconvenience of object notation and accessors:
Now perform that same manipulation on those very same "objects" the easy way:
Of course, that wasn't 'proper OO' above because my methods manipulated the object properties directly, so let's fix that:
But you're still not 'doing it properly' because you didn't name your arguments:
Still wrong! I didn't check my arguments:
Of course, writing all those setters and getters manually is just so 'Legacy Perl'; there are packages that'll do that for me:
Best we don't look. The price of modern convenience! With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|