No special synopsis. Acts like Class::Stds constructor
Does not call BUILD and START (and does not walk down the inheritance hierarchy calling BUILD and START).
Does not perform any attribute initializations.
Really fast, but very basic.
No constructor is exported into the calling class.
The recommended usage is:
If you use the Object Cache (see below) the recommended usage is:
Class::Std sorts the @ISA hierarchy before traversing it to avoid cleaning up the wrong class first. However, this is unneccessary if the class in question has a linear inheritance tree.
Class authors may disable sorting by calling
use Class::Std::Fast unsorted => 1;
Use only if you know your class complete inheritance tree...
use Class::Std::Fast cache => 1;
While inside out objects are basically an implementation of the Flyweight Pattern (object data is stored outside the object), theres still one aspect missing: object reuse. While Class::Std::Fast does not provide flyweights in the classical sense (one object re-used again and again), it provides something close to it: An object cache for re-using destroyed objects.
The object cache is implemented as a simple hash with the class names of the cached objects as keys, and a list ref of cached objects as values.
The object cache is filled by the DESTROY method exported into all Class::Std::Fast based objects: Instead of actually destroying the blessed scalar reference (Class::Std::Fast based objects are nothing more), the object to be destroyed is pushed into its class object cache.
new() in turn does not need to create a new blessed scalar, but can just pop one off the object cache (which is a magnitude faster).
Using the object cache is recommended for persistent applications (like running under mod_perl), or applications creating and destroying lots of Class::Std::Fast based objects again and again.
For an example of a user-defined constructor see Constructors above.
On a 32bit Linux, Devel::Size reports 44 bytes for a Class::Std::Fast based object - so a cache containing 1 000 000 (one million) of objects needs around 50MB of memory (Devel Size only reports the memory use it can see - the actual usage is system dependent and something between 4 and 32 bytes more).
If you are anxious about falling short of memory, only enable caching for those classes whose objects you know to be frequently created and destroyed, and leave it turned off for the less frequently used classes - this gives you both speed benefits, and avoids holding a cache of object that will never be needed again.
Additional diagnostics are:
o Class::Std::Fast loaded too late - put >use Class::Std::Fast< somewhere at the top of your application (warning)
This is due to both classes overwriting UNIVERSAL::can. Class::Std::Fast uses the original (fast) can where appropritate, but cannot access it if Class::Std has overwritten it before with its (slow) replacement.
o version o Class::Std o Carp
o You cant use the :SCALARIFY attribute for your Objects. o Inheriting from non-Class::Std::Fast modules does not work
You cannot inherit from non-Class::Std::Fast classes, not even if you overwrite the default constructor. To be more precise, you cannot inherit from classes which use something different from numeric blessed scalar references as their objects. Even so inheriting from similarly contructed classes like Object::InsideOut could work, you would have to make sure that object IDs cannot be duplicated. It is therefore strongly discouraged to build classes with Class::Std::Fast derived from non-Class::Std::Fast classes.
o No runtime initialization with constructor => basic / none
When evaling Class::Std::Fast based classes using the basic constructor, make sure the last line is
The same holds true for constructor => none, of course.
CUMULATIVE, PRIVATE, RESTRICTED and anticumulative methods wont work if you leave out this line.
Last changed by $Author: ac0v $ Id $Id: Fast.pm 469 2008-05-26 11:26:35Z ac0v $ Revision $Revision: 469 $ Date $Date: 2008-05-26 13:26:35 +0200 (Mon, 26 May 2008) $ HeadURL $HeadURL: file:///var/svn/repos/Hyper/Class-Std-Fast/branches/0.0.8/lib/Class/Std/Fast.pm $
Andreas ac0v Specht <ACID@cpan.org>
Martin Kutter <email@example.com>
Copyright (c) 2007, Andreas Specht <ACID@cpan.org>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|perl v5.20.3||CLASS::STD::FAST (3)||2008-05-26|