Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Speeding-up OO accessor methods

by demerphq (Chancellor)
on Feb 22, 2004 at 11:08 UTC ( [id://330916]=note: print w/replies, xml ) Need Help??


in reply to Speeding-up OO accessor methods

I think a better idea is to use a tied hash as the basis of your class in testing and development, and an untied hash in production release. This way you bypass the requirement for converting from method syntax to hash syntax using a regex. All attributes of the objects are accessed via hash notation. The tie ensures that the keys and values are legal, etc. Then when you switch out of development/test mode, you disable the tie and get the speed benefit of pure hash accesses. You could even selectively enable the tie as required.

I believe that Damian Conway wrote Tie::SecureHash with this in mind, with the added benefit of namespace rules to aid in subclassing. But I think it may also be worth hand coding in some cases.


---
demerphq

    First they ignore you, then they laugh at you, then they fight you, then you win.
    -- Gandhi


Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://330916]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-03-29 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found