Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2022-08-09 07:31 GMT
Find Nodes?
    Voting Booth?

    No recent polls found