Re: Deleting last item of a List
Re: Deleting last item of a List
- Subject: Re: Deleting last item of a List
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 20 Nov 2004 06:50:07 -0800
On 11/19/04 8:37 PM, "Shane Stanley" <email@hidden> wrote:
> On Fri, 19 Nov 2004 20:59:16 -0500, Hanaan Rosenthal wrote:
>
>> So do the lists differ, as I said, in the way the are handled in
>> memory, or not?
>
> Not in the way you suggested. The difference is that one version creates
> a new list, while the other merely modifies an existing list -- the
> efficiency comes from this fact, not anything to do with being spread out
> in memory. To quote from some (now ancient) release notes:
>
> "Unlike concatenation, setting the beginning or end of a list actually
> changes the list. [...] In these cases, we can greatly increase the
> efficiency of our scripts by inserting items rather than concatenating
> them, forming new lists and leaving the old ones as garbage.[...] For the
> record, setting the end of a list is by far the most efficient, and
> setting the beginning is second (because all the items must be slid down
> to make room for a new first item)."
>
> That's from more than 10 years ago, but I seem to recall Chris Nebel
> confirmed here more recently that it is still the case.
Yes - at least the first part. I don't recall hearing about 'beginning'
being slower than 'end' before - it makes good sense as described above -
but insertion at end being much faster than concatenation due to
concatenation requiring building a new list item by item vs. insertion
acting on an existing list without any iteration was confirmed by Chris
several times over the past 5 years.
--
Paul Berkowitz
_______________________________________________
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