6 Moose::Cookbook::Basics::Recipe7 - Making Moose fast with immutable
13 has 'x' => ( isa => 'Int', is => 'ro' );
14 has 'y' => ( isa => 'Int', is => 'rw' );
16 __PACKAGE__->meta->make_immutable;
20 The Moose metaclass API provides a C<make_immutable()> method. Calling
21 this method does two things to your class. First, it makes it
22 faster. In particular, object construction and destruction are
23 effectively "inlined" in your class, and no longer invoke the meta
26 Second, you can no longer make changes via the metaclass API, such as
27 adding attributes. In practice, this won't be a problem, as you rarely
28 need to do this after first loading the class.
32 We strongly recommend you make your classes immutable. It makes your
33 code much faster, with a small compile-time cost. This will be
34 especially noticeable when creating many object.
38 Dave Rolsky E<lt>autarch@urth.orgE<gt>
40 =head1 COPYRIGHT AND LICENSE
42 Copyright 2006-2009 by Infinity Interactive, Inc.
44 L<http://www.iinteractive.com>
46 This library is free software; you can redistribute it and/or modify
47 it under the same terms as Perl itself.