Message76092
What about cases where performance is unimportant, or where the key
function is fast (e.g. an attribute access)? Then something like
bisect(a, x, key=attrgetter('size'))
is easy to write and read. Mightn't this be considered good design,
from some perspectives?
Another thought: if your list is a list of user-defined objects then a
natural way to do the 'decorate' step of DSU might be to add a 'key'
attribute to each object, rather than the usual method of constructing
pairs. (This has the advantage that you might not have to bother with the
'undecorate' step.) With a key argument, bisect could make use of this
technique too.
Disclaimer: I haven't personally had any need for a key argument on
bisect, so all this is hypothetical. That's why I'm asking for real use-
cases. |
|
Date |
User |
Action |
Args |
2008-11-20 10:11:11 | mark.dickinson | set | recipients:
+ mark.dickinson, rhettinger, tebeka |
2008-11-20 10:11:10 | mark.dickinson | set | messageid: <1227175870.76.0.0920267332822.issue4356@psf.upfronthosting.co.za> |
2008-11-20 10:11:09 | mark.dickinson | link | issue4356 messages |
2008-11-20 10:11:08 | mark.dickinson | create | |
|