[Catalyst] Moose's make_immutable in Catalyst classes

Tomas Doran bobtfish at bobtfish.net
Wed Oct 24 07:22:46 GMT 2012

On 24 Oct 2012, at 05:35, Toby Corkindale wrote:
> I was just wondering.. should we be adding Moose's make_immutable call
> to the end of these classes?
> ie. __PACKAGE__->meta->make_immutable;

This makes things faster if you construct lots of them (and also makes things a bit safer, as they can't be changed), at the cost of a bit of startup time.

Generally Catalyst components are only initialised once (i.e. they're scoped to the lifetime of the app), so there is no speed benefit to immutable in this case (actually, it's probably a startup speed reduction), but I still tend to use it for the safety…

So it's entirely optional, in classes which implement ACCEPT_CONTEXT (and so are constructed once per request), you will see a speed benefit from doing it, but this is the less unusual case.. 


More information about the Catalyst mailing list