Re: why not bisect options?



On Feb 29, 1:15 pm, Raymond Hettinger <pyt...@xxxxxxx> wrote:
[Robert Bossy]

I thought it would be useful if insort and consorts* could accept the
same options than list.sort, especially key and cmp.

If you're going to do many insertions or searches, wouldn't it be
*much* more efficient to store your keys in a separate array?

The sort() function guarantees that it calls the key function exactly
once for each member of the list.  With and bisect/insort, successive
searches can call the key function over and over again with the same
value.

Raymond

Since sort time is at least linear, sort ( key, obj ) pairs; return
obj's.
.



Relevant Pages

  • Re: why not bisect options?
    ... same options than list.sort, especially key and cmp. ... If you're going to do many insertions or searches, ... *much* more efficient to store your keys in a separate array? ... The sortfunction guarantees that it calls the key function exactly ...
    (comp.lang.python)
  • [8FOLD] Template #3
    ... "You lead a very eventful life, don't you, Mr. Kidman?" ... lunatics collapsing in the middle of your store... ... threats have some sort of motivation behind them. ...
    (rec.arts.comics.creative)
  • Re: Q: sorts key and cmp parameters
    ... SchwartzSort that's surely not the first standard sort they look ... scripting languages like Python that are primarily used on relatively ... So having a key function is positive. ... more hashes than in C++ code, where I think programmers use them only ...
    (comp.lang.python)
  • Re: Bad feelings in Wickes
    ... to sort it out. ... insisted that I should approach the exit without the carrier bag, ... test if the machine would beep. ... A few years My brother and I went into a Wicks Store and bought a large ...
    (uk.legal)
  • C 128s ROM socket
    ... sort of a new topic, so I didn't reply to that. ... I've thought about that ROM socket in the C128 a lot and have on occasion ... So I'm hoping to use something on the IEC port to store more ... up trying to read/write to a serial flash ram chip via the user port.. ...
    (comp.sys.cbm)