----- Original Message -----
From: Roman Haefeli reduzent@gmail.com To: pd-list@iem.at Cc: Sent: Wednesday, March 13, 2013 1:49 PM Subject: Re: [PD] long list-building time
On Mit, 2013-03-13 at 09:12 -0700, Jonathan Wilkes wrote:
Hi list, See attached for difference between building a list of symbols through [list append] and building an array of symbols.
Now, I know the ds array resizing and setting is more efficient than building out a list using [list append], but I don't understand why the [list append] takes over a minute to complete. It can't be due to symbol table stuff since I'm using the same symbol over and over.
[list append] is not particularly slow, but your algorithm of appending is. You are passing 45000 + 44999 + 44998 + 44997 .... + 1 symbols around, which is obviously very inefficient.
Yes it's slow, but the point is that a) it's not obvious why it would be as slow as it actually is until you get under the hood and look at the source and b) it's the most obvious way to build up a list using the common list processing objects in Pd. Your misunderstanding that the patch is "passing" too many symbols is evidence of the non-obvious of the problem, and Frank's original implementation of [list-drip] is good evidence that accumulating atoms with another [list] object like I showed is the obvious approach for a whole class of list manipulations. (Additionally, matju's newer [list-drip] approach using recursion is a great example of how difficult it is to get a handle on the eccentricities of list processing and get decent efficiency without resorting to externals.)
I added another method to your patch that uses [add $1( to a message box to append many symbols to a list. While the [list append] method takes 15s on my machine, the messagebox method takes only 9 ms.
I don't like solutions that blow up in the user's face when they do something as innocent as leaving a subpatch visible, but I do agree that's the fastest way to build up a list.
Btw-- is there a list-abs object to do the appending in place? I scanned through the objects but didn't see one.
-Jonathan
Roman
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list