in reply to Traditional Linked List and Perl's built-in Data Structure
Basically, almost any tree structure or graph, will use less memory and have faster traversal times, if implemented in C using direct pointer access and manipulations, than when the same structures are built using Perl's references.
As fast as Perl's hashes and arrays are, you do pay some costs for their generality and ease of use. Indirecting through a reference costs more than indirecting through a raw address, and raw C-style arrays use considerably less memory than the equivalent Perl arrays.
However, for those costs, you get a whole slew of benefits:
For anything other than the most demanding of applications that need extremely fast response times, or to manipulate huge amounts of memory, the gains far outweight the costs. And even when you do need to manipulate large volumes of data, a little extra effort can sometimes allow you to accomodate upto an order of magnitude more data in the same amount of ram, whilst still avoiding the need to leave the convenience of Perl and get down and dirty with C.
That said, a well thought out set of tree primitives written in XS, available in Perl would be a nice addition.
Edited by planetscape - added <ul></ul> tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Traditional Linked List and Perl's built-in Data Structure
by ph713 (Pilgrim) on Dec 17, 2005 at 16:08 UTC | |
by BrowserUk (Patriarch) on Dec 17, 2005 at 16:40 UTC |