* Komtanoo Pinpimai <[EMAIL PROTECTED]> [02-11-27 12:06]: > Yesterday, my friend told me that python and php have a built-in > function to search their array. For python he said that python > implements array with something like heap and it benefits for > searching in array !?
PHP conflates "arrays" and "hashes". Arrays are hashes in PHP. I have no info on Python. The nub of your question is: what's the best data structure to use to be able to find elements quickly, but "not use too much memory"? It's true that Perl hashes used a fair bit of memory (my understanding is that each key-value pair uses an order of magnitude more memory than an array element). However, hashes are a case of "trading memory for speed." Because you have a large data set, you might consider using a "hash on disk" file format like Berkley DB or any of the Perl support DBM formats. This solution is slower than an in-memory hash, but uses less memory. You might even consider using a DBMS like MySQL or Postgres if your querying needs grow. > I wonder if "perl list" provides function for searching elements !? > I think it is not good to do a bruteforce search in an unsorted > array. If Perl list is built basing on data structures that enhance > searching, it is possible to provide built-in fuction for searching > !? You can create your own data structures in Perl and search them in the most appropriate way. You can even use XS extensions to create data structures that are faster to build and search. I recommend being lazy and using huge, sloppy globs of RAM to solve your problems. RAM is cheaper than programming time. -- ---------------- Joe Johnston -- http://taskboy.com Software Consultant: Web - Database - Perl "...our power is in argument and persuasion." --Chinua Achebe _______________________________________________ Boston-pm mailing list [EMAIL PROTECTED] http://mail.pm.org/mailman/listinfo/boston-pm

