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

Re^6: how to read multiple line from a file

by educated_foo (Vicar)
on Apr 14, 2013 at 20:56 UTC ( [id://1028647]=note: print w/replies, xml ) Need Help??


in reply to Re^5: how to read multiple line from a file
in thread how to read multiple line from a file

I think try and measure is easier than digging into theoretical calculations...
This has nothing to do with theory. An array is a contiguous chunk of memory. If you put things on one side and take them from the other, you can either shift the current contents, or keep allocating more memory.
Just another Perler interested in Befunge Programming.
  • Comment on Re^6: how to read multiple line from a file

Replies are listed 'Best First'.
Re^7: how to read multiple line from a file
by LanX (Saint) on Apr 14, 2013 at 21:08 UTC
    > This has nothing to do with theory.

    Nonsense! Sorry!

    Taking a short look into the Panther book convinces me that your understanding of AVs is rather oversimplified¹!

    There are mechanisms to optimize the effects of shifts and pushs!

    Anyway others are more qualified to talk about perlguts.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

    ¹) this is not C !

      Or you could just look at av.h. How do you think xav_alloc works?
      Just another Perler interested in Algol Programming.
        Did I mention that in this case benchmarking goes over theory?

        Have no time to dig into details, that's why in the meantime I trust others ...

        see Shift, Pop, Unshift and Push with Impunity!¹

        ... who give me the impression, that Perl arrays have more optimizations than C-Arrays do.

        > How do you think xav_alloc works?

        I'm no C-Programmer ... but did I mention that I prefer benchmarking before digging into theory?

        Cheers Rolf

        ( addicted to the Perl Programming Language)

        updates

        ¹) excerpt:

        In comparison, a stack implemented with a perl list will only require reallocations as the list grows larger. However, perl is smartly coded because the use of lists as queues was anticipated. Consequently, these queue-type reallocations have a negligible impact on performance. In benchmarked tests, queue access of a list (using repeated push/shift operations) is nearly as fast as stack access to a list (using repeated push/pop operations).

        emphasize added!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2024-04-18 11:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found