[Dbix-class] Using Class::Std under-the-hood

Dan Kubb dan.kubb at autopilotmarketing.com
Thu Aug 11 09:05:35 CEST 2005

> What are the performance implications of using Class::Std?

 From Class::Std docs:

   "Of the several popular methods of reliably enforcing  
encapsulation in Perl,
   inside-out objects are also by far the cheapest. The run-time  
performance of
   inside-out classes is effectively identical to that of regular  
   classes. In particular, in both schemes, every attribute access  
requires only
   a single hash look-up. The only appreciable difference in speed  
occurs when
   an inside-out object is destroyed."

And later Damian says:

   "There is a simple, convenient, and utterly secure way to prevent  
client code
   from accessing the internals of the objects you provide. Happily,  
that approach
   also guards against misspelling attribute names (a common error in  
   classes), as well as being just as fast as--and often more memory- 
   than--ordinary hash-based objects."

As fast as -- and *more* memory efficient. ;)

> One of the things that make DBIx::Class promising is the reduced  
> overhead as
> compared to Class::DBI. If the fundamental building blocks are  
> changed to
> something that greatly increases the overhead, I personally do not  
> see a net
> gain. Yes, I like encapsulation, etc, etc.

The truth is that if we use something other than blessed hash objects
there is going to be some overhead.  If we are concerned about  
attribute lookups we should look into an array based object instead.

Will there be any appreciable difference in performance either way?  I
doubt it, especially when compared with the other operations being  
by DBIx::Class.


Dan Kubb

More information about the Dbix-class mailing list