Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Efficiency and length of variable names

by rozallin (Curate)
on Mar 12, 2005 at 13:47 UTC ( #438908=note: print w/ replies, xml ) Need Help??


in reply to Efficiency and length of variable names

In answer to your question, larger variable and subroutine names will certainly take up more memory than shorter ones. In most programs and scripts the difference in performance however is so minor (i.e. almost negligible) as to not be a real concern.

If speed is of the utmost priority there are a number of programming style points which have a more significant impact on performance than the length of names; using hashes instead of linear searches, using next if to reject common cases early before you split or chop, avoiding regular expressions with many quantifiers and using s/// when concatenating strings to name a couple of examples. You might find it worth your while to read the Efficiency section (Chapter 8 Section 8.3) of Programming Perl.

Remember, however, that there are different types of efficiency (such as space and readability/maintainability) and some of them aren't worth sacrificing for speed. Writing code with one-letter global variable names might give you a slight speed advantage now, but if you won't recognise what they symbolise when you come to re-visit the code in six months you're going to waste valuable programming time.

-- rozallin
rozallin@livejournal.com


Comment on Re: Efficiency and length of variable names
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2014-07-25 08:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (170 votes), past polls