On Sun, 24 Oct 2010 14:47:43 -0400 bearophile <bearophileh...@lycos.com> wrote:
> Manfred_Nowak: > > > arrays are computational not well suited for deleting elements, nor are > > lists. Sequences of all kinds are the worst possible kind of collection for this operation (not only linear search, but shift all elements placed after the one found & removed). But... > On the other hand dynamic arrays are handy for many other purposes. So if you > have just 20 items, like some buttons of your GUI, you may want to use a > dynamic array to add and remove them, especially if you have handy standard > functions/methods to add and remove items. The runtime, even in Python, will > never show you any slowdown. Python lists are arrays dynamic to the right, > similar to D dynamic arrays, and they are handy. > > So computational complexity considerations aren't the only things to keep in > account when you write code. ... Agreed. Typically, remove and such costly ops happen once in a while, when indexing, traversal, slicing for which sequences are handy and super-efficient happen all the time. Bearophile, what do you mean with "arrays dynamic to the right"? (that they extend/compress (only) on the right side?) > Bye, > bearophile Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.com