Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Perl stores the number of keys in the hash as an independent property. So accessing this data is always O(1).

Note that this is not true of code that does if (%hash){} or otherwise inspects the *fill* of a hash using scalar %hash (note the omission of the keys() function). Such code, depending on the version, will be inefficient. In later perls the if() case is special cased to not use "fill", and in 5.20 scalar %hash will likely be equivalent to scalar keys %hash.

---
$world=~s/war/peace/g


In reply to Re: performance of counting keys in a big hash by demerphq
in thread performance of counting keys in a big hash by xufengnju

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [Corion]: thezip: I would expect some (fancier?) numeric formatting to fail from these test failures
    [1nickt]: ( Sometimes when idle I browse remote corners of the code repo at $work ... usually this yields knowledge of projects to decline and coworkers to avoid ... )
    [LanX]: sure
    [Corion]: 1nickt: Finding autobox in production would give me pause, yes
    [LanX]: efficient survey
    [MidLifeXis]: And under MINGW64_NT-6.1 MYHOST 2.6.0(0.304/5/3) 2016-09-09 09:46 x86_64 Msys there seem to be issues with escapes in external build tool calls.
    [Corion]: I mean, it's a technical feat it achieves, but... why? ;)
    [MidLifeXis]: And it also has the 0.14 version of the tarball in its manifest.
    [LanX]: avoiding unreadable brackets
    [MidLifeXis]: Although the previous one could be a b0rken PATH, I would need to dig for that.

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (13)
    As of 2017-03-23 17:24 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Should Pluto Get Its Planethood Back?



      Results (291 votes). Check out past polls.