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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

In reply to Re: Efficiency and length of variable names by rozallin
in thread Efficiency and length of variable names by moggs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-03-28 15:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found