in reply to Re^3: POE OO sessions - accessing overwritten methods
in thread POE OO sessions - accessing overwritten methods

POE actually answers the question Why does POE pass parameters as array slices? with: Perl functions receive their parameter values in a special list, @_. This is faster and shorter than passing parameters by hash or hashref.

See http://poe.perl.org/?POE_FAQ/calling_convention.
  • Comment on Re^4: POE OO sessions - accessing overwritten methods

Replies are listed 'Best First'.
Re^5: POE OO sessions - accessing overwritten methods
by Tanktalus (Canon) on Feb 12, 2005 at 16:48 UTC

    Interesting. But they are quite wrong (see above). They start out with a factual truth: passing in by @_ is fastest. (I wonder if passing in a single array ref would be faster ... one way to find out!) However, they then go and explain how they'll use this "fast" method to go and make it readable and extendable. Well, guess what. It's not.

    Rather than starting out with the fastest method and making it more readable, they should have evaluated all methods, and picked the most readable and fast method. They discarded all alternatives over a perceived speed difference, and then used up way more than that speed difference in making it readable. Kudos for making it readable and forward-thinking. A pox for thinking inside an artificial box.

    Update: Yes, a major typo in the code screwed this up. Ok, so it's not significantly slower. I still think it's unreadable :-)

    Short version: The calling types they said would be slower than "normal" are. But they're all faster than the one they ended up with. The unintuitiveness of this style still causes problems. As in calling SUPER.

      Interesting. But they are quite wrong (see above).

      Actually, you're quite wrong. And if you learnt to use strict you'd have seen your mistake.

      Here are the results of your benchmark once your mistake is corrected.

      [18:46:32.42] P:\test>junk Rate Ref_Named Named Ref_Copy Shift POE + Normal Ref_Named 119185/s -- -3% -35% -81% -83% + -84% Named 122333/s 3% -- -34% -81% -83% + -84% Ref_Copy 183991/s 54% 50% -- -71% -74% + -76% Shift 639848/s 437% 423% 248% -- -9% + -17% POE 701269/s 488% 473% 281% 10% -- + -9% Normal 768699/s 545% 528% 318% 20% 10% + --
      And that should absolutely zero surprise to anyone: OBJECT, KERNEL, HEAP, and SESSION are all subs which would mean subroutine calls.

      You're the one in for the surprise. They aren't subroutine calls, they are constant subroutine calls. What difference does that make?

      It means that at compile time, Perl can detect that they are constant subroutines.

      [18:43:58.10] P:\test>perl -MO=Deparse -e"use constant{ONE=>1,TWO=>2}; + for( ONE .. TWO) { print }" use constant ({'ONE', 1, 'TWO', 2}); foreach $_ (1 .. 2) { print $_; } -e syntax OK

      Did you spot your error yet? use strict would have told you way back up ^ there somewhere--but I guess that is another "artificial box" you'd rather stay out of.

      So, what do you think we should put a pox on now? Flying by the seat of your pants! :)


      Examine what is said, not who speaks.
      Silence betokens consent.
      Love the truth but pardon error.

        I swear - I type

        #!/usr/bin/perl -w use strict;
        as second nature. But this time, doing a benchmark, I got confused... and forgot to add it back in. I guess I'm doing K.P. duty for the monastary this week...