Class::...or::Fast(3)

πŸ’… NAME πŸ’…

Class::Accessor::Fast β€” accessors that go zoom, but like… don't expect them to grow wings and fly, bestie

so this is a page from the User Contributed Perl Documentation corner of the universe, and honestly? she's serving efficiency. let's get into it πŸ¦‹


✨ SYNOPSIS ✨

package Foo;
use base qw(Class::Accessor::Fast);

# The rest is the same as Class::Accessor but without set() and get().

literally just that. no notes. πŸŽ€


🌸 DESCRIPTION 🌸

okay so. Class::Accessor::Fast is the faster-but-less-expandable sibling of Class::Accessor. same vibes, less flexibility, more speed. it's giving "I'm not complicated, I'm efficient."

here's the tea β˜•: the accessors that Class::Accessor generates need two method calls to do their little task β€” one for the accessor itself, and then another one for get() or set(). two trips. two whole round-trips, like she's stopping at the drive-thru on the way to work.

Class::Accessor::Fast said "not me doing all that" and eliminates calling set()/get() entirely β€” she does the access herself. result? a somewhat faster accessor. slay πŸ’…

the downside (and yes there's always a downside, there's always a catch, it's never just vibes 😭): you can't easily alter the behavior of your accessors, and neither can your subclasses. that's the trade. that's the whole deal. no customization arc for you.

but bestie, it's fine, because if you need that flexibility later you can always swap out Class::Accessor::Fast for Class::Accessor. it's a whole use base line. you'll survive 🫢

Read the documentation for Class::Accessor for more info β€” she's the main character, this one's the spin-off.

πŸ”₯ EFFICIENCY πŸ”₯

"EFFICIENCY" in Class::Accessor for an efficiency comparison. (yes, that's the whole thing, go look at the other page for the receipts, iykyk πŸ‘‘)


πŸ‘‘ AUTHORS πŸ‘‘

Copyright 2017 Marty Pauley <marty+perl@martian.org>

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. That means either (a) the GNU General Public License or (b) the Artistic License. β€” so like, pick your flavor, both are iconic ✨

🧚 ORIGINAL AUTHOR 🧚

Michael G Schwern <schwern@pobox.com> β€” the OG, the founder, the one who started it all, we stan 🌈


🌟 SEE ALSO 🌟

  • Class::Accessor β€” go read her, fr fr, she's the whole reference for this one πŸ’–

okay that's the page!! and for the record, this was rendered out by perl v5.42.0 on 2017-10-23, page Class::...or::Fast(3) β€” a certified vintage. mwah, drink some water, go write some accessors πŸ“πŸ’œ

πŸ“¦ where this page comes from