I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2009-01-07 12:39:30-08 by jdhedden in response to 9663
Re: Generating thousands of objects
While I have tried to optimize OIO whenever possible, the rapid generation and destruction of many objects is a bane for OIO. If the objects are trivial in nature, perhaps just using ordinary hash-based objects would make more sense. Another option might be to use a "recycling bin" for objects:
package MyClass; { use Object::InsideOut; my @myattr :Field :Std(myattr); # Class specific object recycling my @recycle_bin; sub GetObj { return (pop(@recycle_bin)) if (@recycle_bin); return MyClass->new(); } sub Recycle { push(@recycle_bin, shift); } } package main; MAIN: { # Get a new or recycled object my $obj = MyClass::GetObj(); # Initialize object $obj->set_myattr(27); # Use object print $obj->get_myattr(), "\n"; # Recycle object MyClass::Recycle($obj); }
The above limits object initialization, but doubtless it could be improved upon.

I cannot comment on Moose's immutable option because I do not know how Moose manages objects and their methods.
Direct Responses: 9675 | Write a response