Re: Working with big lists
Re: Working with big lists
- Subject: Re: Working with big lists
- From: has <email@hidden>
- Date: Mon, 23 May 2005 10:37:18 +0100
Rob Stott wrote:
>>Use a more efficient algorithm. You should only need to scan each line in the file once, whereas your current routine scans each line N times (where N is the number of lines in the file) - horribly inefficient.
[minor correction to above: should read "where N is the number of unique lines", which in the worst case is same as the number of lines in the file]
>Yep, that's what was bothering me - it seemed like a nasty way of going about it but I couldn't think of an alternative. That chunk of Python REALLY speeds things up. Thanks for that.
Dunno how it compares to the sort + unique approach for raw speed (either via shell or rolling your own in vanilla AS), though I think the dictionary-based counter approach is more elegant and flexible. Satimage's XMLLib osax would probably be the best third-party dictionary substitute if you want to do it in AS. Either way, what matters is avoiding the quadratic-or-worse inefficiencies of the naive algorithm, as that's what really kills you as the amount of data rises.
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden