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

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!

  • Comment on Re^9: how to read multiple line from a file

Replies are listed 'Best First'.
Re^10: how to read multiple line from a file
by educated_foo (Vicar) on Apr 16, 2013 at 14:34 UTC
    perl is smartly coded because the use of lists as queues was anticipated
    This is what I meant about memcpy(). I'm surprised that repeatedly shifting an array over doesn't have a noticeable cost, but I believe the numbers. Point taken.
    Just another Perler interested in Algol Programming.