On Mon, 10 Jan 2005 17:52:42 +0100, Bulba! <[EMAIL PROTECTED]> wrote:
>I don't see why should deleting element from a list be O(n), while
>saying L[0]='spam' when L[0] previously were, say, 's', not have the
>O(n) cost, if a list in Python is just an array containing the
>objects itself?
>
>Why s
On Sun, 09 Jan 2005 22:51:47 GMT, Andrea Griffini <[EMAIL PROTECTED]>
wrote:
>>Tip 1: Once you have data in memory, don't move it, move a pointer or
>>index over the parts you are inspecting.
>>
>>Tip 2: Develop an abhorrence of deleting data.
>
>I've to admit that I also found strange that deleti
John Machin wrote:
My wild guess: Not a common use case. Double-ended queue is a special
purpose structure.
As Kent said, the suggestion of making index 0 insertions and deletions on lists
more efficent was made, and the decision was to leave list alone and provide
collections.deque instead. This
On 9 Jan 2005 16:03:34 -0800, "John Machin" <[EMAIL PROTECTED]>
wrote:
>My wild guess: Not a common use case. Double-ended queue is a special
>purpose structure.
>
>Note that the OP could have implemented the 3-tape update simulation
>efficiently by reading backwards i.e. del alist[-1]
Note that
Andrea Griffini wrote:
I've to admit that I also found strange that deleting the
first element from a list is not O(1) in python. My wild
guess was that the extra addition and normalization required
to have insertion in amortized O(1) and deletion in O(1) at
both ends of a random access sequence wa
Andrea Griffini wrote:
> On 9 Jan 2005 12:39:32 -0800, "John Machin" <[EMAIL PROTECTED]>
> wrote:
>
> >Tip 1: Once you have data in memory, don't move it, move a pointer
or
> >index over the parts you are inspecting.
> >
> >Tip 2: Develop an abhorrence of deleting data.
>
> I've to admit that I al
On 9 Jan 2005 12:39:32 -0800, "John Machin" <[EMAIL PROTECTED]>
wrote:
>Tip 1: Once you have data in memory, don't move it, move a pointer or
>index over the parts you are inspecting.
>
>Tip 2: Develop an abhorrence of deleting data.
I've to admit that I also found strange that deleting the
first
Bulba! wrote:
> On 8 Jan 2005 18:25:56 -0800, "John Machin" <[EMAIL PROTECTED]>
> wrote:
>
> >Secondly, you are calling cmp() up to THREE times when once is
enough.
> >Didn't it occur to you that your last elif needed an else to finish
it
> >off, and the only possible action for the else suite was
On Sat, 08 Jan 2005 17:57:30 -0700, Steven Bethard
<[EMAIL PROTECTED]> wrote:
>Note that Python lists are implemented basically as arrays, which means
>that deleting an item from anywhere but the end of the list is O(n)
>because all items in the list must be moved down to fill the hole.
Ouch...
On 8 Jan 2005 18:25:56 -0800, "John Machin" <[EMAIL PROTECTED]>
wrote:
>> Both versions use local variables, etc. Both have their
>> lists initially sorted. Both essentially use a loop with
>> conditional for comparison,
>> then process the record in the
>> same way.
>
>"process the record in the
Bulba! wrote:
> On 4 Jan 2005 14:33:34 -0800, "John Machin" <[EMAIL PROTECTED]>
> wrote:
>
> >(b) Fast forwarding 30+ years, let's look at the dictionary method,
> >assuming you have enough memory to hold all your data at once:
> >
> >Step 1: read the "left" table; for each row, if english not in
Bulba! wrote:
Following advice of two posters here (thanks) I have written two
versions of the same program, and both of them work, but the
difference in speed is drastic, about 6 seconds vs 190 seconds
for about 15000 of processed records, taken from 2 lists of
dictionaries.
I've read "Python Per
On 4 Jan 2005 14:33:34 -0800, "John Machin" <[EMAIL PROTECTED]>
wrote:
>(b) Fast forwarding 30+ years, let's look at the dictionary method,
>assuming you have enough memory to hold all your data at once:
>
>Step 1: read the "left" table; for each row, if english not in mydict,
>then do mydict[engl
13 matches
Mail list logo