Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re (tilly) 1: Speeding-up OO accessor methods

by tilly (Archbishop)
on Sep 19, 2000 at 01:17 UTC ( #33031=note: print w/replies, xml ) Need Help??

in reply to Speeding-up OO accessor methods

You improve it by using a hash and if one day you want it to be something else then you will just tie the hash to an OO implementation.

To tie it all you need to do is provide a class with the OO interface Perl is looking for, then call tie on the data structure you wish to tie.

Note that the correct documentation is in perldoc perltie - and this is one area where Perl has improved significantly over releases so looking at your local documentation Really Matters On This One.

  • Comment on Re (tilly) 1: Speeding-up OO accessor methods

Replies are listed 'Best First'.
RE: Re (tilly) 1: Speeding-up OO accessor methods
by mirod (Canon) on Sep 19, 2000 at 01:20 UTC

    I admit I haven'd done any benchmarking here, but aren't tie-ed variables slower than a simple hash access? The whole point of this hack is to get some speed.</pp>

      The whole point of this hack as I see it is to write a ton of code so in the long run you could switch the implementation from hash access (fast) to something slower but more flexible.

      Being prepared to move to a tied interface later gives you that flexibility without any loss in speed or extra coding and development effort up front. Downstream that extra time will likely matter more anyways.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://33031]
and the grasshoppers chirp...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2018-02-24 08:41 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (310 votes). Check out past polls.