Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

For what it's worth, Mouse is much more than 25% faster than Moose (at least it is on machines where it's been compiled with XS; Mouse::PurePerl is very slightly slower than Moose). While it appears to offer good compatibility with Moose; this is on the surface only. Things start to break if you try to consume a Mouse role in Moose, or extend a Moose class with Mouse.

Moo has far less of a start-up penalty than Moose, but when it comes to running speed, isn't quite as fast. On the surface it appears less Moose-compatible (but see MooX::late) but it's designed to be able to interact nicely with Moose. You can extend Moo classes with Moose, consume Moose roles in Moo, etc.

The only places I can see big scope for Moose optimization are:

  • Allow inlining for things like defaults, triggers and coercions. This would slow down the speed at which your class loads, but improve the speed at which it runs.
  • Rewrite large parts of the internals in XS. This would likely improve the speed of Moose itself, but not alter the speed of your class. (It would also make maintenance of Moose more annoying, and thus turn away developers.)

I've published a couple of modules on CPAN that might be of use if you're trying to eke a little more speed out of a lumbering Moose...

  • Type::Tiny - a type constraint system that's a little faster than Moose's built-in ones. (I have benchmarked it.)
  • MooseX::XSAccessor - which replaces some of your accessor methods with faster XS-based ones, but only when it detects that it can do so without breaking any functionality. (Again, I have benchmarked it.)
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

In reply to Re^2: A "Perl-7" that I could actually USE right now by tobyink
in thread A "Perl-7" that I could actually USE right now by sundialsvc4

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (6)
    As of 2024-09-18 12:32 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      The PerlMonks site front end has:





      Results (24 votes). Check out past polls.

      Notices?
      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.