in reply to Module Readonly

You are correct in saying constant creates a subroutine. Specifically, it's a sub in the form sub NAME () { 'value' }. The empty prototype is a hint to the compiler that the value can be inlined.

The reason Readonly is slow is that it relies on a tied interface--in other words, it's an object pretending to be one of Perl's native datatypes.

One alternative is Scalar::Readonly, which sets an internal flag on a scalar (SvREADONLY). This is the flag set by certain special internal variables by Perl to make them readonly, and Scalar::Readonly lets you fiddle with it. I would be very surprised if this affected performance at all (save for the initial setting of the flag).

----
: () { :|:& };:

Note: All code is untested, unless otherwise stated