in reply to Re^3: why doesn't constant work?
in thread why doesn't constant work?
Readonly is a lovely module, but a small caveat about Readonly - if you don't have control over the Perl interpreter that will be running your script, you may suffer a significant performance penalty using Readonly, espcially if your script or application needs to use the constants to process large batches of information (e.g. Bioinformatics)
According to the documentation, Readonly is about 20x slower than Constant unless it dedetcts the module Readonly::XS is installed. If the XS module is installed, then scalar readonly constants will be about the same speed as non-scalar constants (the XS modules simply flips the scalar's read-only bit in the underlying C-code). However, this works only for scalar constants. For all other constants (arrays, hashes) you still have the speed penalty.
If your script will run on a statically installed version of Perl, you will have to recompile the Perl binary to include the XS module (it isn't part of the standard compile). To include XS module in dynamically linked Perl interpreters, you at least need permission to compile and install C libraries - not always a straight forward matter in corporate environments or when you are developing for a client environment rather than one you have personal control over.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: why doesn't constant work?
by JavaFan (Canon) on Nov 11, 2010 at 14:08 UTC |